gokaygokay commited on
Commit
cd63ff7
·
1 Parent(s): 15ad9e5
Files changed (1) hide show
  1. app.py +30 -5
app.py CHANGED
@@ -204,6 +204,23 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondar
204
  output_image = gr.Image(label="Result", elem_id="gallery", show_label=False)
205
  used_seed = gr.Number(label="Seed Used")
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  def update_llm_visibility(use_llm):
208
  return {
209
  llm_provider: gr.update(visible=use_llm),
@@ -217,15 +234,23 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue", secondar
217
  outputs=[llm_provider, llm_model, prompt_type]
218
  )
219
 
 
 
 
 
 
 
220
  def generate_prompt(image, text_prompt, use_enhancer, use_llm_generator, llm_provider, llm_model, prompt_type):
221
  if image is not None:
222
  caption = florence_caption(image)
223
- if use_llm_generator:
224
- prompt = generate_llm_prompt(caption, llm_provider, llm_model, prompt_type)
225
- else:
226
- prompt = caption
 
 
227
  else:
228
- prompt = text_prompt
229
 
230
  if use_enhancer:
231
  prompt = enhance_prompt(prompt)
 
204
  output_image = gr.Image(label="Result", elem_id="gallery", show_label=False)
205
  used_seed = gr.Number(label="Seed Used")
206
 
207
+ def update_model_choices(provider):
208
+ provider_models = {
209
+ "Hugging Face": [
210
+ "Qwen/Qwen2.5-72B-Instruct",
211
+ "meta-llama/Meta-Llama-3.1-70B-Instruct",
212
+ "mistralai/Mixtral-8x7B-Instruct-v0.1",
213
+ "mistralai/Mistral-7B-Instruct-v0.3"
214
+ ],
215
+ "SambaNova": [
216
+ "Meta-Llama-3.1-70B-Instruct",
217
+ "Meta-Llama-3.1-405B-Instruct",
218
+ "Meta-Llama-3.1-8B-Instruct"
219
+ ],
220
+ }
221
+ models = provider_models.get(provider, [])
222
+ return gr.Dropdown(choices=models, value=models[0] if models else "")
223
+
224
  def update_llm_visibility(use_llm):
225
  return {
226
  llm_provider: gr.update(visible=use_llm),
 
234
  outputs=[llm_provider, llm_model, prompt_type]
235
  )
236
 
237
+ llm_provider.change(
238
+ update_model_choices,
239
+ inputs=[llm_provider],
240
+ outputs=[llm_model]
241
+ )
242
+
243
  def generate_prompt(image, text_prompt, use_enhancer, use_llm_generator, llm_provider, llm_model, prompt_type):
244
  if image is not None:
245
  caption = florence_caption(image)
246
+ initial_prompt = caption
247
+ else:
248
+ initial_prompt = text_prompt
249
+
250
+ if use_llm_generator:
251
+ prompt = generate_llm_prompt(initial_prompt, llm_provider, llm_model, prompt_type)
252
  else:
253
+ prompt = initial_prompt
254
 
255
  if use_enhancer:
256
  prompt = enhance_prompt(prompt)