Pijush2023 commited on
Commit
1f33e71
·
verified ·
1 Parent(s): 8fa1e7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -46
app.py CHANGED
@@ -1125,48 +1125,10 @@ def handle_model_choice_change(selected_model):
1125
  # Default case: allow interaction
1126
  return gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
1127
 
1128
- # import gradio as gr
1129
- # import torch
1130
- # from diffusers import FluxPipeline
1131
- # from PIL import Image
1132
-
1133
- # # Load the Flux pipeline
1134
- # flux_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
1135
- # flux_pipe.enable_model_cpu_offload() # Save some VRAM by offloading to CPU if needed
1136
-
1137
- # # Function to generate image using Flux
1138
- # def generate_flux_image(prompt: str):
1139
- # generator = torch.Generator("cpu").manual_seed(0) # For reproducibility
1140
- # image = flux_pipe(
1141
- # prompt,
1142
- # guidance_scale=0.0,
1143
- # num_inference_steps=4,
1144
- # max_sequence_length=256,
1145
- # generator=generator
1146
- # ).images[0]
1147
-
1148
- # # Save image temporarily and return for display
1149
- # temp_image_path = f"temp_flux_image_{hash(prompt)}.png"
1150
- # image.save(temp_image_path)
1151
-
1152
- # return temp_image_path
1153
-
1154
- # # Hardcoded prompts for generating images
1155
- # hardcoded_prompt_1 = "A high quality cinematic image for Toyota Truck in Birmingham skyline shot in the style of Michael Mann"
1156
- # hardcoded_prompt_2 = "A high quality cinematic image for Alabama Quarterback close up emotional shot in the style of Michael Mann"
1157
- # hardcoded_prompt_3 = "A high quality cinematic image for Taylor Swift concert in Birmingham skyline style of Michael Mann"
1158
-
1159
- # # Generate the images immediately
1160
- # img1_path = generate_flux_image(hardcoded_prompt_1)
1161
- # img2_path = generate_flux_image(hardcoded_prompt_2)
1162
- # img3_path = generate_flux_image(hardcoded_prompt_3)
1163
-
1164
-
1165
  import gradio as gr
1166
  import torch
1167
  from diffusers import FluxPipeline
1168
  from PIL import Image
1169
- import time
1170
 
1171
  # Load the Flux pipeline
1172
  flux_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
@@ -1196,12 +1158,10 @@ hardcoded_prompt_3 = "A high quality cinematic image for Taylor Swift concert in
1196
 
1197
  # Generate the images immediately
1198
  img1_path = generate_flux_image(hardcoded_prompt_1)
1199
- time.sleep(2) # Wait for 2 seconds before generating the next image
 
1200
 
1201
- img2_path = generate_flux_image(hardcoded_prompt_2)
1202
- time.sleep(2) # Wait for 2 seconds before generating the next image
1203
 
1204
- img3_path = generate_flux_image(hardcoded_prompt_3)
1205
 
1206
 
1207
 
@@ -1503,12 +1463,10 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
1503
 
1504
  with gr.Column():
1505
  # Display the pre-generated images directly
1506
- # image_output_1 = gr.Image(value=img1_path)
1507
  # image_output_2 = gr.Image(value=img2_path)
1508
  # image_output_3 = gr.Image(value=img3_path)
1509
- image_output_1 = gr.Image(value=img1_path, label="Image 1")
1510
- image_output_2 = gr.Image(value=img2_path, label="Image 2")
1511
- image_output_3 = gr.Image(value=img3_path, label="Image 3")
1512
 
1513
 
1514
 
 
1125
  # Default case: allow interaction
1126
  return gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)
1127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  import gradio as gr
1129
  import torch
1130
  from diffusers import FluxPipeline
1131
  from PIL import Image
 
1132
 
1133
  # Load the Flux pipeline
1134
  flux_pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
 
1158
 
1159
  # Generate the images immediately
1160
  img1_path = generate_flux_image(hardcoded_prompt_1)
1161
+ # img2_path = generate_flux_image(hardcoded_prompt_2)
1162
+ # img3_path = generate_flux_image(hardcoded_prompt_3)
1163
 
 
 
1164
 
 
1165
 
1166
 
1167
 
 
1463
 
1464
  with gr.Column():
1465
  # Display the pre-generated images directly
1466
+ image_output_1 = gr.Image(value=img1_path)
1467
  # image_output_2 = gr.Image(value=img2_path)
1468
  # image_output_3 = gr.Image(value=img3_path)
1469
+
 
 
1470
 
1471
 
1472