Spaces:
Runtime error
Runtime error
TA
commited on
Commit
·
21db197
1
Parent(s):
d75bf46
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import requests
|
@@ -75,43 +76,22 @@ def test_preview_chatbot(message, history):
|
|
75 |
response = predict_beta(message, history, SYSTEM_PROMPT)
|
76 |
return response
|
77 |
|
78 |
-
# Create a Gradio custom component for image and prompt
|
79 |
-
class ImagePromptComponent(gr.Component):
|
80 |
-
def __init__(self, image_url, prompt):
|
81 |
-
self.image_url = image_url
|
82 |
-
self.prompt = prompt
|
83 |
-
super().__init__()
|
84 |
-
|
85 |
-
def to_html(self):
|
86 |
-
return f"""
|
87 |
-
<div>
|
88 |
-
<img src='{self.image_url}' alt='Image' style='width:100px;height:100px;'>
|
89 |
-
<p>{self.prompt}</p>
|
90 |
-
</div>
|
91 |
-
"""
|
92 |
-
|
93 |
-
# Generate instances of the custom component
|
94 |
-
image_prompt_components = [
|
95 |
-
ImagePromptComponent(EXAMPLE_INPUTS[i]['image_url'], EXAMPLE_INPUTS[i]['prompt']) for i in range(4)
|
96 |
-
]
|
97 |
-
|
98 |
# Display HTML and launch the interface
|
99 |
gr.Interface(
|
100 |
fn=test_preview_chatbot,
|
101 |
live=False,
|
102 |
examples=[[EXAMPLE_INPUTS[0]['prompt']]],
|
103 |
-
inputs=
|
104 |
outputs=gr.Textbox(),
|
105 |
layout="vertical",
|
106 |
html=html_temp.format(
|
107 |
-
image_url_1=
|
108 |
-
prompt_1=
|
109 |
-
image_url_2=
|
110 |
-
prompt_2=
|
111 |
-
image_url_3=
|
112 |
-
prompt_3=
|
113 |
-
image_url_4=
|
114 |
-
prompt_4=
|
115 |
),
|
116 |
).launch(share=True)
|
117 |
-
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
import requests
|
|
|
76 |
response = predict_beta(message, history, SYSTEM_PROMPT)
|
77 |
return response
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
# Display HTML and launch the interface
|
80 |
gr.Interface(
|
81 |
fn=test_preview_chatbot,
|
82 |
live=False,
|
83 |
examples=[[EXAMPLE_INPUTS[0]['prompt']]],
|
84 |
+
inputs=gr.Textbox(scale=7, container=False, value=EXAMPLE_INPUTS[0]['prompt']),
|
85 |
outputs=gr.Textbox(),
|
86 |
layout="vertical",
|
87 |
html=html_temp.format(
|
88 |
+
image_url_1=EXAMPLE_INPUTS[0]["image_url"],
|
89 |
+
prompt_1=EXAMPLE_INPUTS[0]["prompt"],
|
90 |
+
image_url_2=EXAMPLE_INPUTS[1]["image_url"],
|
91 |
+
prompt_2=EXAMPLE_INPUTS[1]["prompt"],
|
92 |
+
image_url_3=EXAMPLE_INPUTS[2]["image_url"],
|
93 |
+
prompt_3=EXAMPLE_INPUTS[2]["prompt"],
|
94 |
+
image_url_4=EXAMPLE_INPUTS[3]["image_url"],
|
95 |
+
prompt_4=EXAMPLE_INPUTS[3]["prompt"],
|
96 |
),
|
97 |
).launch(share=True)
|
|