Akbartus commited on
Commit
c429527
1 Parent(s): 332c75d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -9,6 +9,7 @@ import re
9
  from PIL import Image
10
  from gradio_client import Client, handle_file
11
  from huggingface_hub import login
 
12
 
13
  MAX_SEED = np.iinfo(np.int32).max
14
 
@@ -45,7 +46,7 @@ def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_factor, p
45
 
46
  image, seed = generate_image(prompt, model, "", width, height, scales, steps, seed)
47
  if image is None:
48
- return [None]
49
 
50
  image_path = "temp_image.jpg"
51
  image.save(image_path, format="JPEG")
@@ -55,13 +56,12 @@ def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_factor, p
55
  if upscale_image_path is not None:
56
  upscale_image = Image.open(upscale_image_path)
57
  upscale_image.save("upscale_image.jpg", format="JPEG")
58
- return [upscale_image]
59
  else:
60
  print("Error: The scaled image path is None")
61
- return [image]
62
  else:
63
- return [image]
64
-
65
 
66
  css = """
67
  #col-container{ margin: 0 auto; max-width: 1024px;}
@@ -71,7 +71,7 @@ with gr.Blocks(css=css) as demo:
71
  with gr.Column(elem_id="col-container"):
72
  with gr.Row():
73
  with gr.Column(scale=3):
74
- output_res = gr.Image(label="Generated Image") # Using gr.Image instead of ImageSlider
75
  with gr.Column(scale=2):
76
  prompt = gr.Textbox(label="Image Description")
77
  basemodel_choice = gr.Dropdown(label="Model", choices=["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV", "enhanceaiteam/Flux-uncensored", "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro", "Shakker-Labs/FLUX.1-dev-LoRA-add-details", "city96/FLUX.1-dev-gguf"], value="black-forest-labs/FLUX.1-schnell")
@@ -89,5 +89,4 @@ with gr.Blocks(css=css) as demo:
89
 
90
  btn = gr.Button("Generate")
91
  btn.click(fn=gen, inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora], outputs=output_res,)
92
-
93
- demo.launch()
 
9
  from PIL import Image
10
  from gradio_client import Client, handle_file
11
  from huggingface_hub import login
12
+ from gradio_imageslider import ImageSlider
13
 
14
  MAX_SEED = np.iinfo(np.int32).max
15
 
 
46
 
47
  image, seed = generate_image(prompt, model, "", width, height, scales, steps, seed)
48
  if image is None:
49
+ return [None, None]
50
 
51
  image_path = "temp_image.jpg"
52
  image.save(image_path, format="JPEG")
 
56
  if upscale_image_path is not None:
57
  upscale_image = Image.open(upscale_image_path)
58
  upscale_image.save("upscale_image.jpg", format="JPEG")
59
+ return [image_path, "upscale_image.jpg"]
60
  else:
61
  print("Error: The scaled image path is None")
62
+ return [image_path, image_path]
63
  else:
64
+ return [image_path, image_path]
 
65
 
66
  css = """
67
  #col-container{ margin: 0 auto; max-width: 1024px;}
 
71
  with gr.Column(elem_id="col-container"):
72
  with gr.Row():
73
  with gr.Column(scale=3):
74
+ output_res = ImageSlider(label="Flux / Upscaled")
75
  with gr.Column(scale=2):
76
  prompt = gr.Textbox(label="Image Description")
77
  basemodel_choice = gr.Dropdown(label="Model", choices=["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV", "enhanceaiteam/Flux-uncensored", "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro", "Shakker-Labs/FLUX.1-dev-LoRA-add-details", "city96/FLUX.1-dev-gguf"], value="black-forest-labs/FLUX.1-schnell")
 
89
 
90
  btn = gr.Button("Generate")
91
  btn.click(fn=gen, inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora], outputs=output_res,)
92
+ demo.launch()