Spaces:
Runtime error
Runtime error
SMeyersMrOvkill
commited on
Commit
•
40b8949
1
Parent(s):
03b33e1
0.555
Browse files
app.py
CHANGED
@@ -89,47 +89,46 @@ Complete Description:
|
|
89 |
return res.choices[0].text.split("```")[0]
|
90 |
|
91 |
def xform_image_description(img, inst):
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
|
100 |
with gr.Blocks() as demo:
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
demo.launch(debug=True, share=True)
|
|
|
89 |
return res.choices[0].text.split("```")[0]
|
90 |
|
91 |
def xform_image_description(img, inst):
|
92 |
+
#md = MoonDream()
|
93 |
+
from together import Together
|
94 |
+
desc = dual_images(img)
|
95 |
+
tog = Together(api_key=os.getenv("TOGETHER_KEY"))
|
96 |
+
prompt=f"""Describe the image in aggressively verbose detail. I must know every freckle upon a man's brow and each blade of the grass intimately.\nDescription: ```text\n{desc}\n```\nInstructions:\n```text\n{inst}\n```\n\n\n---\nDetailed Description:\n```text"""
|
97 |
+
res = tog.completions.create(prompt=prompt, model="meta-llama/Meta-Llama-3-70B", stop=["```"], max_tokens=1024)
|
98 |
+
return res.choices[0].text[len(prompt):].split("```")[0]
|
99 |
|
100 |
with gr.Blocks() as demo:
|
101 |
+
with gr.Row(visible=True):
|
102 |
+
with gr.Column():
|
103 |
+
img = gr.Image(label="images", type='pil')
|
104 |
+
with gr.Column():
|
105 |
+
otpt = gr.Textbox(label="output", lines=3, interactive=True)
|
106 |
+
btn = gr.Button("submit")
|
107 |
+
with gr.Row():
|
108 |
+
with gr.Column():
|
109 |
+
im1 = gr.Image(label="image 1", type='pil')
|
110 |
+
otp2 = gr.Textbox(label="image 1", interactive=True)
|
111 |
+
with gr.Column():
|
112 |
+
im2 = gr.Image(label="image 2", type='pil')
|
113 |
+
otp3 = gr.Textbox(label="image 2")
|
114 |
+
with gr.Row():
|
115 |
+
minst = gr.Textbox(label="Merge Instructions")
|
116 |
+
with gr.Row():
|
117 |
+
btn2 = gr.Button("submit batch")
|
118 |
+
with gr.Row():
|
119 |
+
with gr.Column():
|
120 |
+
im1 = gr.Image(label="image 1", type='pil')
|
121 |
+
otp2 = gr.Textbox(label="individual batch output (left)", interactive=True)
|
122 |
+
with gr.Column():
|
123 |
+
im2 = gr.Image(label="image 2", type='pil')
|
124 |
+
otp3 = gr.Textbox(label="individual batch output (right)", interactive=True)
|
125 |
+
with gr.Row():
|
126 |
+
otp4 = gr.Textbox(label="batch output ( combined )", interactive=True, lines=4)
|
127 |
+
with gr.Row():
|
128 |
+
btn_scd = gr.Button("Merge Descriptions to Single Combined Description")
|
129 |
+
btn2.click(dual_images, inputs=[im1], outputs=[otp2])
|
130 |
+
btn2.click(dual_images, inputs=[im2], outputs=[otp3])
|
131 |
+
btn.click(dual_images, inputs=[img], outputs=[otpt])
|
132 |
+
btn_scd.click(merge_descriptions_to_prompt, inputs=[minst, otp2, otp3], outputs=[otp4])
|
133 |
+
|
134 |
+
demo.launch(debug=True, share=True)
|
|