kidsampson commited on
Commit
6134078
·
verified ·
1 Parent(s): b078f2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -1,25 +1,35 @@
1
- # import gradio as gr
2
-
3
- # def greet(name):
4
- # return "Hello " + name + "!!"
5
-
6
- # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- # demo.launch()
8
-
9
  import gradio as gr
10
  from transformers import pipeline
11
 
12
- pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
13
 
14
- def predict(image):
15
- predictions = pipeline(image)
16
- return {p["label"]: p["score"] for p in predictions}
17
 
18
  demo = gr.Interface(
19
- predict,
20
- inputs=gr.Image(label="Upload hot dog candidate", type="filepath"),
21
- outputs=gr.Label(num_top_classes=2),
22
- title="Hot Dog? Or Not?",
23
  )
24
 
25
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B-Instruct")
5
 
6
+ def response(messages):
7
+ message = ["{"role": "user", "content": "+messages+"},"]
8
+ return pipe(message)
9
 
10
  demo = gr.Interface(
11
+ response,
12
+ inputs=gr.Label[gr.Textbox(label="Input your question: ", lines=3)],
13
+ outputs=gr.Label[gr.Textbox(label="Here's the answer: ", lines = 3)],
14
+ title="Ask me anything!",
15
  )
16
 
17
+ demo.launch()
18
+
19
+ # import gradio as gr
20
+ # from transformers import pipeline
21
+
22
+ # pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
23
+
24
+ # def predict(image):
25
+ # predictions = pipeline(image)
26
+ # return {p["label"]: p["score"] for p in predictions}
27
+
28
+ # demo = gr.Interface(
29
+ # predict,
30
+ # inputs=gr.Image(label="Upload hot dog candidate", type="filepath"),
31
+ # outputs=gr.Label(num_top_classes=2),
32
+ # title="Hot Dog? Or Not?",
33
+ # )
34
+
35
+ # demo.launch()