coztomate commited on
Commit
b2a7d1e
·
1 Parent(s): 2a415c1

231228: update diffusion

Browse files
Files changed (1) hide show
  1. app.py +36 -8
app.py CHANGED
@@ -184,6 +184,7 @@ with st.expander("Press Text Generation Zone"):
184
 
185
  # Add a text input for the HF key
186
  hf_key_mistral = st.secrets["hf_key"]
 
187
 
188
 
189
  #defaults for Mistral
@@ -336,7 +337,7 @@ with st.expander("Image Generation Territory"):
336
  if st.button("Generate Image from New Caption of Artwork"):
337
  if st.session_state['new_caption']:
338
  prompt_caption = f"contemporary art of {st.session_state['new_caption']}"
339
- st.session_state['image_from_caption'] = client.text_to_image(prompt_caption)
340
 
341
  # Display the image generated from new caption
342
  if st.session_state['image_from_caption'] is not None:
@@ -346,7 +347,7 @@ with st.expander("Image Generation Territory"):
346
  if st.button("Generate Image from Simplified Text"):
347
  if st.session_state['simplified_text']:
348
  prompt_summary = f"contemporary art of {st.session_state['simplified_text']}"
349
- st.session_state['image_from_simplified_text'] = client.text_to_image(prompt_summary)
350
 
351
  # Display the image generated from simplified text
352
  if st.session_state['image_from_simplified_text'] is not None:
@@ -354,9 +355,20 @@ with st.expander("Image Generation Territory"):
354
 
355
  # Button to generate image from press text from simplified text
356
  if st.button("Generate Image from new Press Text from Simplified Text"):
357
- if st.session_state['message_content_from_simplified_text']:
358
- prompt_press_text = f"contemporary art of {st.session_state['message_content_from_simplified_text']}"
359
- st.session_state['image_from_press_text'] = client.text_to_image(prompt_press_text)
 
 
 
 
 
 
 
 
 
 
 
360
 
361
  # Display the image generated from press text from simplified text
362
  if st.session_state['image_from_press_text'] is not None:
@@ -364,14 +376,30 @@ with st.expander("Image Generation Territory"):
364
  caption="Image from Press Text from simplified Text",
365
  use_column_width=True)
366
 
 
367
  # Button to generate image from press text from caption
368
  if st.button("Generate Image from new Press Text from new Caption"):
369
- if st.session_state['message_content_from_caption']:
370
- prompt_press_text_caption = f"contemporary art of {st.session_state['message_content_from_caption']}"
371
- st.session_state['image_from_press_text_from_caption'] = client.text_to_image(prompt_press_text_caption)
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  # Display the image generated from press text from caption
374
  if st.session_state['image_from_press_text_from_caption'] is not None:
375
  st.image(st.session_state['image_from_press_text_from_caption'],
376
  caption="Image from Press Text from new Caption",
377
  use_column_width=True)
 
 
 
 
184
 
185
  # Add a text input for the HF key
186
  hf_key_mistral = st.secrets["hf_key"]
187
+
188
 
189
 
190
  #defaults for Mistral
 
337
  if st.button("Generate Image from New Caption of Artwork"):
338
  if st.session_state['new_caption']:
339
  prompt_caption = f"contemporary art of {st.session_state['new_caption']}"
340
+ st.session_state['image_from_caption'] = client.text_to_image(prompt_caption, model="prompthero/openjourney-v4")
341
 
342
  # Display the image generated from new caption
343
  if st.session_state['image_from_caption'] is not None:
 
347
  if st.button("Generate Image from Simplified Text"):
348
  if st.session_state['simplified_text']:
349
  prompt_summary = f"contemporary art of {st.session_state['simplified_text']}"
350
+ st.session_state['image_from_simplified_text'] = client.text_to_image(prompt_summary, model="prompthero/openjourney-v4")
351
 
352
  # Display the image generated from simplified text
353
  if st.session_state['image_from_simplified_text'] is not None:
 
355
 
356
  # Button to generate image from press text from simplified text
357
  if st.button("Generate Image from new Press Text from Simplified Text"):
358
+ text_to_use = None
359
+
360
+ # Check which variable is available and set it to text_to_use
361
+ if 'mistral_from_simplified' in st.session_state and st.session_state['mistral_from_simplified']:
362
+ text_to_use = st.session_state['mistral_from_simplified']
363
+ elif 'message_content_from_simplified_text' in st.session_state and st.session_state['message_content_from_simplified_text']:
364
+ text_to_use = st.session_state['message_content_from_simplified_text']
365
+
366
+ # Use the available text to generate the image
367
+ if text_to_use:
368
+ prompt_press_text_simple = f"contemporary art of {text_to_use}"
369
+ st.session_state['image_from_press_text'] = client.text_to_image(prompt_press_text_simple, model="prompthero/openjourney-v4")
370
+ else:
371
+ st.error("First generate a caption.")
372
 
373
  # Display the image generated from press text from simplified text
374
  if st.session_state['image_from_press_text'] is not None:
 
376
  caption="Image from Press Text from simplified Text",
377
  use_column_width=True)
378
 
379
+
380
  # Button to generate image from press text from caption
381
  if st.button("Generate Image from new Press Text from new Caption"):
382
+ # Initialize the variable
383
+ text_to_use_cap = None
384
+
385
+ # Check which variable is available and set it to text_to_use
386
+ if 'mistral_from_caption' in st.session_state and st.session_state['mistral_from_caption']:
387
+ text_to_use_cap = st.session_state['mistral_from_caption']
388
+ elif 'message_content_from_caption' in st.session_state and st.session_state['message_content_from_caption']:
389
+ text_to_use_cap = st.session_state['message_content_from_caption']
390
+
391
+ # Use the available text to generate the image
392
+ if text_to_use_cap:
393
+ prompt_press_text_caption = f"contemporary art of {text_to_use_cap}"
394
+ st.session_state['image_from_press_text_from_caption'] = client.text_to_image(prompt_press_text_caption, model="prompthero/openjourney-v4")
395
+ else:
396
+ st.error("First generate a caption.")
397
 
398
  # Display the image generated from press text from caption
399
  if st.session_state['image_from_press_text_from_caption'] is not None:
400
  st.image(st.session_state['image_from_press_text_from_caption'],
401
  caption="Image from Press Text from new Caption",
402
  use_column_width=True)
403
+
404
+ st.markdown("---")
405
+