Spaces:
Build error
Build error
Switch back to Docker
Browse files- blah β Dockerfile +0 -0
- README.md +1 -1
- app.py +20 -15
blah β Dockerfile
RENAMED
File without changes
|
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
title: FROMAGe
|
3 |
emoji: π§
|
4 |
-
sdk:
|
5 |
app_file: app.py
|
6 |
colorFrom: blue
|
7 |
colorTo: red
|
|
|
1 |
---
|
2 |
title: FROMAGe
|
3 |
emoji: π§
|
4 |
+
sdk: docker
|
5 |
app_file: app.py
|
6 |
colorFrom: blue
|
7 |
colorTo: red
|
app.py
CHANGED
@@ -39,7 +39,7 @@ class FromageChatBot:
|
|
39 |
return filename
|
40 |
|
41 |
|
42 |
-
def generate_for_prompt(self, input_text, state, ret_scale_factor,
|
43 |
input_prompt = 'Q: ' + input_text + '\nA:'
|
44 |
self.chat_history += input_prompt
|
45 |
|
@@ -50,7 +50,12 @@ class FromageChatBot:
|
|
50 |
else:
|
51 |
model_inputs = [self.chat_history]
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
im_names = []
|
56 |
response = ''
|
@@ -77,24 +82,24 @@ class FromageChatBot:
|
|
77 |
|
78 |
|
79 |
def launch(self):
|
80 |
-
with gr.Blocks(
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
text_input = gr.Textbox(show_label=False, placeholder="Upload an image [optional]. Then enter a text prompt, and press enter!").style(container=False)
|
87 |
-
with gr.Column(scale=0.15, min_width=0):
|
88 |
-
image_btn = gr.UploadButton("Image", file_types=["image"])
|
89 |
-
|
90 |
-
with gr.Row():
|
91 |
-
with gr.Column(scale=0.20, min_width=0):
|
92 |
-
clear_btn = gr.Button("Clear")
|
93 |
ret_scale_factor = gr.Slider(minimum=0.0, maximum=3.0, value=1.0, step=0.1, interactive=True, label="Multiplier for returning images (higher means more frequent)")
|
94 |
max_ret_images = gr.Number(minimum=0, maximum=3, value=1, precision=1, interactive=True, label="Max images to return")
|
95 |
gr_max_len = gr.Number(value=32, precision=1, label="Max # of words returned", interactive=True)
|
96 |
gr_temperature = gr.Number(value=0.0, label="Temperature", interactive=True)
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
text_input.submit(self.generate_for_prompt, [text_input, gr_state, ret_scale_factor, max_ret_images, gr_max_len, gr_temperature], [gr_state, chatbot])
|
99 |
image_btn.upload(self.upload_image, [gr_state, image_btn], [gr_state, chatbot])
|
100 |
clear_btn.click(self.reset, [], [gr_state, chatbot])
|
|
|
39 |
return filename
|
40 |
|
41 |
|
42 |
+
def generate_for_prompt(self, input_text, state, ret_scale_factor, max_nm_rets, num_words, temperature):
|
43 |
input_prompt = 'Q: ' + input_text + '\nA:'
|
44 |
self.chat_history += input_prompt
|
45 |
|
|
|
50 |
else:
|
51 |
model_inputs = [self.chat_history]
|
52 |
|
53 |
+
top_p = 1.0
|
54 |
+
if temp != 0.0:
|
55 |
+
top_p = 0.95
|
56 |
+
model_outputs = self.model.generate_for_images_and_texts(model_inputs,
|
57 |
+
num_words=num_words, ret_scale_factor=ret_scale_factor, top_p=top_p,
|
58 |
+
temperature=temperature, max_num_rets=max_nm_rets)
|
59 |
|
60 |
im_names = []
|
61 |
response = ''
|
|
|
82 |
|
83 |
|
84 |
def launch(self):
|
85 |
+
with gr.Blocks() as demo:
|
86 |
+
gr.Markdown(
|
87 |
+
'### Grounding Language Models to Images for Multimodal Generation'
|
88 |
+
)
|
89 |
+
|
90 |
+
with gr.Column(scale=0.3, min_width=0):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
ret_scale_factor = gr.Slider(minimum=0.0, maximum=3.0, value=1.0, step=0.1, interactive=True, label="Multiplier for returning images (higher means more frequent)")
|
92 |
max_ret_images = gr.Number(minimum=0, maximum=3, value=1, precision=1, interactive=True, label="Max images to return")
|
93 |
gr_max_len = gr.Number(value=32, precision=1, label="Max # of words returned", interactive=True)
|
94 |
gr_temperature = gr.Number(value=0.0, label="Temperature", interactive=True)
|
95 |
|
96 |
+
with gr.Column(scale=0.7, min_width=0):
|
97 |
+
image_btn = gr.UploadButton("Image Input", file_types=["image"])
|
98 |
+
text_input = gr.Textbox(label="Text Input", placeholder="Upload an image [optional]. Then enter a text prompt, and press enter!")
|
99 |
+
chatbot = gr.Chatbot()
|
100 |
+
gr_state = gr.State([])
|
101 |
+
clear_btn = gr.Button("Clear History")
|
102 |
+
|
103 |
text_input.submit(self.generate_for_prompt, [text_input, gr_state, ret_scale_factor, max_ret_images, gr_max_len, gr_temperature], [gr_state, chatbot])
|
104 |
image_btn.upload(self.upload_image, [gr_state, image_btn], [gr_state, chatbot])
|
105 |
clear_btn.click(self.reset, [], [gr_state, chatbot])
|