Spaces:
Runtime error
Runtime error
Hotdog + Chatbot
Browse files
app.py
CHANGED
@@ -1,18 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
predictions = pipeline(input_img)
|
8 |
-
return input_img, {p["label"]: p["score"] for p in predictions}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
gradio_app = gr.Interface(
|
11 |
-
predict,
|
12 |
-
inputs=
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
)
|
16 |
|
17 |
-
if
|
18 |
gradio_app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
pipeline_hotdog = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
5 |
|
6 |
+
chatbot_pipeline = pipeline(task="text-generation", model="microsoft/DialoGPT-medium")
|
|
|
|
|
7 |
|
8 |
+
def predict(input_img,chat_input):
|
9 |
+
hotdog_predictions = pipeline_hotdog(input_img)
|
10 |
+
# Generate chatbot response
|
11 |
+
chatbot_response = chatbot_pipeline(chat_input, max_length=50)[0]['generated_text']
|
12 |
+
|
13 |
+
return input_img, {
|
14 |
+
"Hotdog Classification": {p["label"]: p["score"] for p in hotdog_predictions},
|
15 |
+
"Chatbot Response": chatbot_response
|
16 |
+
}
|
17 |
+
|
18 |
gradio_app = gr.Interface(
|
19 |
+
fn=predict,
|
20 |
+
inputs=[
|
21 |
+
gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
|
22 |
+
gr.Textbox(label="Chatbot Input", placeholder="Type something to chat with the bot")
|
23 |
+
],
|
24 |
+
outputs=[
|
25 |
+
gr.Image(label="Processed Image"),
|
26 |
+
gr.Label(label="Hotdog Classification", num_top_classes=2),
|
27 |
+
gr.Textbox(label="Chatbot Response", output_transform=lambda x: x["Chatbot Response"], type="readonly")
|
28 |
+
],
|
29 |
+
title="Hot Dog? Or Not? with Chatbot",
|
30 |
)
|
31 |
|
32 |
+
if _name_ == "_main_":
|
33 |
gradio_app.launch()
|