ysharma HF staff commited on
Commit
99642bc
·
1 Parent(s): 39daff5

update saved file name

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -55,6 +55,9 @@ def chat(image_in, in_steps, in_guidance_scale, in_img_guidance_scale, image_hid
55
  with open(temp_img_name, "wb") as fp:
56
  # Save the image to the file-like object
57
  edited_image.save(fp)
 
 
 
58
  #edited_image.save(temp_img_name) #, overwrite=True)
59
  counter_out += 1
60
  else:
@@ -68,6 +71,9 @@ def chat(image_in, in_steps, in_guidance_scale, in_img_guidance_scale, image_hid
68
  with open(img_name, "wb") as fp:
69
  # Save the image to the file-like object
70
  edited_image.save(fp)
 
 
 
71
  #edited_image.save(img_name) #, overwrite=True) #("/tmp/edited_image.png") #(img_nm)
72
  #counter_out += 1
73
  history = history or []
@@ -75,12 +81,12 @@ def chat(image_in, in_steps, in_guidance_scale, in_img_guidance_scale, image_hid
75
  add_text_list = ["There you go", "Enjoy your image!", "Nice work! Wonder what you gonna do next!", "Way to go!", "Does this work for you?", "Something like this?"]
76
  if counter_out > 0:
77
  #response = edited_image
78
- response = random.choice(add_text_list) + '<img src="/file=' + temp_img_name + '">'
79
  history.append((prompt, response))
80
  return history, history, edited_image, temp_img_name, counter_out
81
  else:
82
  #response = edited_image
83
- response = random.choice(add_text_list) + '<img src="/file=' + img_name + '">'
84
  history.append((prompt, response))
85
  counter_out += 1
86
  return history, history, edited_image, img_name, counter_out
 
55
  with open(temp_img_name, "wb") as fp:
56
  # Save the image to the file-like object
57
  edited_image.save(fp)
58
+ #Get the name of the saved image
59
+ saved_image_name = fp.name
60
+ print(f"SAVED IMAGE NAME : {saved_image_name}, TMP IMAGE NAME : {temp_img_name}")
61
  #edited_image.save(temp_img_name) #, overwrite=True)
62
  counter_out += 1
63
  else:
 
71
  with open(img_name, "wb") as fp:
72
  # Save the image to the file-like object
73
  edited_image.save(fp)
74
+ #Get the name of the saved image
75
+ saved_image_name2 = fp.name
76
+ print(f"SAVED IMAGE NAME : {saved_image_name2}, IMAGE NAME : {img_name}")
77
  #edited_image.save(img_name) #, overwrite=True) #("/tmp/edited_image.png") #(img_nm)
78
  #counter_out += 1
79
  history = history or []
 
81
  add_text_list = ["There you go", "Enjoy your image!", "Nice work! Wonder what you gonna do next!", "Way to go!", "Does this work for you?", "Something like this?"]
82
  if counter_out > 0:
83
  #response = edited_image
84
+ response = random.choice(add_text_list) + '<img src="/file=' + saved_image_name + '">' #temp_img_name
85
  history.append((prompt, response))
86
  return history, history, edited_image, temp_img_name, counter_out
87
  else:
88
  #response = edited_image
89
+ response = random.choice(add_text_list) + '<img src="/file=' + saved_image_name2 + '">' #IMG_NAME
90
  history.append((prompt, response))
91
  counter_out += 1
92
  return history, history, edited_image, img_name, counter_out