ysharma HF staff commited on
Commit
176f241
·
1 Parent(s): bcd0b3f

update code to handle bug in image save

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -38,16 +38,13 @@ be to the input. This pipeline requires a value of at least `1`. It's possible y
38
  * Cropping the image so the face takes up a larger portion of the frame.
39
  """
40
 
41
- def chat(image_in, in_steps, in_guidance_scale, in_img_guidance_scale, image_hid, img_name, counter_out, prompt, history, progress=gr.Progress(track_tqdm=True)):
42
- progress(0, desc="Starting...")
43
- #global counter
44
- #counter += 1
45
  #if message == "revert": --to add revert functionality later
46
  print(f"counter:{counter_out}, prompt:{prompt}, img_name:{img_name}")
47
  if counter_out > 0:
48
  # Open the image
49
- image_in = Image.open(img_name) #("edited_image.png") #(img_nm)
50
- edited_image = pipe(prompt, image=image_in, num_inference_steps=int(in_steps), guidance_scale=float(in_guidance_scale), image_guidance_scale=float(in_img_guidance_scale)).images[0]
51
  if os.path.exists(img_name):
52
  os.remove(img_name)
53
  edited_image.save(img_name) #, overwrite=True)
@@ -81,7 +78,7 @@ with gr.Blocks() as demo:
81
  in_steps = gr.Number(label="Enter the number of Inference steps", value = 20)
82
  in_guidance_scale = gr.Slider(1,10, step=0.5, label="Set Guidance scale", value=7.5)
83
  in_img_guidance_scale = gr.Slider(1,10, step=0.5, label="Set Image Guidance scale", value=1.5)
84
- image_hid = gr.Image(visible=False,)
85
  img_name_temp_out = gr.Textbox(visible=False)
86
  counter_out = gr.Number(visible=False, value=0)
87
  chatbot = gr.Chatbot()
 
38
  * Cropping the image so the face takes up a larger portion of the frame.
39
  """
40
 
41
+ def chat(image_in, in_steps, in_guidance_scale, in_img_guidance_scale, image_hid, img_name, counter_out, prompt, history): #, progress=gr.Progress(track_tqdm=True)):
 
 
 
42
  #if message == "revert": --to add revert functionality later
43
  print(f"counter:{counter_out}, prompt:{prompt}, img_name:{img_name}")
44
  if counter_out > 0:
45
  # Open the image
46
+ #image_in = Image.open(img_name) #("edited_image.png") #(img_nm)
47
+ edited_image = pipe(prompt, image=image_hid, num_inference_steps=int(in_steps), guidance_scale=float(in_guidance_scale), image_guidance_scale=float(in_img_guidance_scale)).images[0]
48
  if os.path.exists(img_name):
49
  os.remove(img_name)
50
  edited_image.save(img_name) #, overwrite=True)
 
78
  in_steps = gr.Number(label="Enter the number of Inference steps", value = 20)
79
  in_guidance_scale = gr.Slider(1,10, step=0.5, label="Set Guidance scale", value=7.5)
80
  in_img_guidance_scale = gr.Slider(1,10, step=0.5, label="Set Image Guidance scale", value=1.5)
81
+ image_hid = gr.Image(visible=False,type='pil')
82
  img_name_temp_out = gr.Textbox(visible=False)
83
  counter_out = gr.Number(visible=False, value=0)
84
  chatbot = gr.Chatbot()