Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -124,92 +124,4 @@ if __name__ == "__main__":
|
|
124 |
|
125 |
|
126 |
|
127 |
-
|
128 |
-
# if chat_state is not None:
|
129 |
-
# chat_state.messages = []
|
130 |
-
# if img_list is not None:
|
131 |
-
# img_list = []
|
132 |
-
# return None, gr.update(value=None, interactive=True), gr.update(placeholder='Please upload your image first',
|
133 |
-
# interactive=False), gr.update(
|
134 |
-
# value="Upload & Start Chat", interactive=True), chat_state, img_list
|
135 |
-
#
|
136 |
-
#
|
137 |
-
# def upload_img(gr_img, text_input, chat_state):
|
138 |
-
# if gr_img is None:
|
139 |
-
# return None, None, gr.update(interactive=True), chat_state, None
|
140 |
-
# chat_state = CONV_VISION.copy()
|
141 |
-
# img_list = []
|
142 |
-
# llm_message = chat.upload_img(gr_img, chat_state, img_list)
|
143 |
-
# return gr.update(interactive=False), gr.update(interactive=True, placeholder='Type and press Enter'), gr.update(
|
144 |
-
# value="Start Chatting", interactive=False), chat_state, img_list
|
145 |
-
#
|
146 |
-
#
|
147 |
-
# def gradio_ask(user_message, chatbot, chat_state):
|
148 |
-
# if len(user_message) == 0:
|
149 |
-
# return gr.update(interactive=True, placeholder='Input should not be empty!'), chatbot, chat_state
|
150 |
-
# chat.ask(user_message, chat_state)
|
151 |
-
# chatbot = chatbot + [[user_message, None]]
|
152 |
-
# return '', chatbot, chat_state
|
153 |
-
#
|
154 |
-
#
|
155 |
-
# def gradio_answer(chatbot, chat_state, img_list, num_beams, temperature):
|
156 |
-
# llm_message = \
|
157 |
-
# chat.answer(conv=chat_state, img_list=img_list, max_new_tokens=300, num_beams=1, temperature=temperature,
|
158 |
-
# max_length=2000)[0]
|
159 |
-
# chatbot[-1][1] = llm_message
|
160 |
-
# return chatbot, chat_state, img_list
|
161 |
-
#
|
162 |
-
#
|
163 |
-
# title = """<h1 align="center">Demo of MiniGPT-4</h1>"""
|
164 |
-
# description = """<h3>This is the demo of MiniGPT-4. Upload your images and start chatting!</h3>"""
|
165 |
-
# article = """<div style='display:flex; gap: 0.25rem; '><a href='https://minigpt-4.github.io'><img src='https://img.shields.io/badge/Project-Page-Green'></a><a href='https://github.com/Vision-CAIR/MiniGPT-4'><img src='https://img.shields.io/badge/Github-Code-blue'></a><a href='https://github.com/TsuTikgiau/blip2-llm/blob/release_prepare/MiniGPT_4.pdf'><img src='https://img.shields.io/badge/Paper-PDF-red'></a></div>
|
166 |
-
# """
|
167 |
-
#
|
168 |
-
# # TODO show examples below
|
169 |
-
#
|
170 |
-
# with gr.Blocks() as demo:
|
171 |
-
# gr.Markdown(title)
|
172 |
-
# gr.Markdown(SHARED_UI_WARNING)
|
173 |
-
# gr.Markdown(description)
|
174 |
-
# gr.Markdown(article)
|
175 |
-
#
|
176 |
-
# with gr.Row():
|
177 |
-
# with gr.Column(scale=0.5):
|
178 |
-
# image = gr.Image(type="pil")
|
179 |
-
# upload_button = gr.Button(value="Upload & Start Chat", interactive=True, variant="primary")
|
180 |
-
# clear = gr.Button("Restart")
|
181 |
-
#
|
182 |
-
# num_beams = gr.Slider(
|
183 |
-
# minimum=1,
|
184 |
-
# maximum=5,
|
185 |
-
# value=1,
|
186 |
-
# step=1,
|
187 |
-
# interactive=True,
|
188 |
-
# label="beam search numbers)",
|
189 |
-
# )
|
190 |
-
#
|
191 |
-
# temperature = gr.Slider(
|
192 |
-
# minimum=0.1,
|
193 |
-
# maximum=2.0,
|
194 |
-
# value=1.0,
|
195 |
-
# step=0.1,
|
196 |
-
# interactive=True,
|
197 |
-
# label="Temperature",
|
198 |
-
# )
|
199 |
-
#
|
200 |
-
# with gr.Column():
|
201 |
-
# chat_state = gr.State()
|
202 |
-
# img_list = gr.State()
|
203 |
-
# chatbot = gr.Chatbot(label='MiniGPT-4')
|
204 |
-
# text_input = gr.Textbox(label='User', placeholder='Please upload your image first', interactive=False)
|
205 |
-
#
|
206 |
-
# upload_button.click(upload_img, [image, text_input, chat_state],
|
207 |
-
# [image, text_input, upload_button, chat_state, img_list])
|
208 |
-
#
|
209 |
-
# text_input.submit(gradio_ask, [text_input, chatbot, chat_state], [text_input, chatbot, chat_state]).then(
|
210 |
-
# gradio_answer, [chatbot, chat_state, img_list, num_beams, temperature], [chatbot, chat_state, img_list]
|
211 |
-
# )
|
212 |
-
# clear.click(gradio_reset, [chat_state, img_list], [chatbot, image, text_input, upload_button, chat_state, img_list],
|
213 |
-
# queue=False)
|
214 |
-
#
|
215 |
-
# demo.launch(enable_queue=True)
|
|
|
124 |
|
125 |
|
126 |
|
127 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|