Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,25 +7,28 @@ hotdog_pipeline = pipeline(task="image-classification", model="julien-c/hotdog-n
|
|
7 |
# Load the chatbot model (DialoGPT)
|
8 |
chatbot_pipeline = pipeline(task="text-generation", model="microsoft/DialoGPT-medium")
|
9 |
|
10 |
-
def predict(input_data, option):
|
11 |
if option == "Image Classification":
|
12 |
# Predict hotdog or not
|
13 |
hotdog_predictions = hotdog_pipeline(input_data)
|
14 |
return input_data, {
|
15 |
"Hotdog Classification": {p["label"]: p["score"] for p in hotdog_predictions},
|
|
|
16 |
}
|
17 |
elif option == "Chatbot":
|
18 |
# Generate chatbot response
|
19 |
-
chatbot_response = chatbot_pipeline(
|
20 |
return input_data, {
|
21 |
-
"
|
|
|
22 |
}
|
23 |
|
24 |
iface = gr.Interface(
|
25 |
fn=predict,
|
26 |
inputs=[
|
27 |
gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
|
28 |
-
gr.Dropdown(label="Choose Option", choices=["Image Classification", "Chatbot"])
|
|
|
29 |
],
|
30 |
outputs=[
|
31 |
gr.Image(label="Processed Image"),
|
|
|
7 |
# Load the chatbot model (DialoGPT)
|
8 |
chatbot_pipeline = pipeline(task="text-generation", model="microsoft/DialoGPT-medium")
|
9 |
|
10 |
+
def predict(input_data, option, chat_input=""):
|
11 |
if option == "Image Classification":
|
12 |
# Predict hotdog or not
|
13 |
hotdog_predictions = hotdog_pipeline(input_data)
|
14 |
return input_data, {
|
15 |
"Hotdog Classification": {p["label"]: p["score"] for p in hotdog_predictions},
|
16 |
+
"Chatbot Response": "", # Placeholder for chatbot response when not selected
|
17 |
}
|
18 |
elif option == "Chatbot":
|
19 |
# Generate chatbot response
|
20 |
+
chatbot_response = chatbot_pipeline(chat_input, max_length=50)[0]['generated_text']
|
21 |
return input_data, {
|
22 |
+
"Hotdog Classification": {},
|
23 |
+
"Chatbot Response": chatbot_response,
|
24 |
}
|
25 |
|
26 |
iface = gr.Interface(
|
27 |
fn=predict,
|
28 |
inputs=[
|
29 |
gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
|
30 |
+
gr.Dropdown(label="Choose Option", choices=["Image Classification", "Chatbot"]),
|
31 |
+
gr.Textbox(label="Chatbot Input", placeholder="Type something to chat with the bot", type="text"),
|
32 |
],
|
33 |
outputs=[
|
34 |
gr.Image(label="Processed Image"),
|