SMeyersMrOvkill commited on
Commit
40b8949
1 Parent(s): 03b33e1
Files changed (1) hide show
  1. app.py +41 -42
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
- #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.Row():
103
- img = gr.Image(label="images", type='pil')
104
- with gr.Row():
105
- btn = gr.Button("submit")
106
- with gr.Row():
107
- otpt = gr.Textbox(label="output", lines=3, interactive=True)
108
- with gr.Row():
109
- with gr.Column():
110
- im1 = gr.Image(label="image 1", type='pil')
111
- otp2 = gr.Textbox(label="image 1", interactive=True)
112
- with gr.Column():
113
- im2 = gr.Image(label="image 2", type='pil')
114
- otp3 = gr.Textbox(label="image 2")
115
- with gr.Row():
116
- minst = gr.Textbox(label="Merge Instructions")
117
- with gr.Row():
118
- btn2 = gr.Button("submit batch")
119
- with gr.Row():
120
- with gr.Column():
121
- im1 = gr.Image(label="image 1", type='pil')
122
- otp2 = gr.Textbox(label="individual batch output (left)", interactive=True)
123
- with gr.Column():
124
- im2 = gr.Image(label="image 2", type='pil')
125
- otp3 = gr.Textbox(label="individual batch output (right)", interactive=True)
126
- with gr.Row():
127
- otp4 = gr.Textbox(label="batch output ( combined )", interactive=True, lines=4)
128
- with gr.Row():
129
- btn_scd = gr.Button("Merge Descriptions to Single Combined Description")
130
- btn2.click(dual_images, inputs=[im1], outputs=[otp2])
131
- btn2.click(dual_images, inputs=[im2], outputs=[otp3])
132
- btn.click(dual_images, inputs=[img], outputs=[otpt])
133
- btn_scd.click(merge_descriptions_to_prompt, inputs=[minst, otp2, otp3], outputs=[otp4])
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)