Spaces:
Potre1qw
/
Running on Zero

Potre1qw commited on
Commit
cc4291a
1 Parent(s): 0463ff0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -75,11 +75,15 @@ def check_server_ready(port):
75
  return False
76
 
77
  @spaces.GPU(duration=170)
78
- def generate_image(image):
79
  prefix_filename = str(random.randint(0, 999999))
80
- prompt = read_prompt_from_file('config.json')
81
- prompt = json.dumps(prompt, ensure_ascii=False).replace('output_image', prefix_filename)
82
- prompt = json.loads(prompt)
 
 
 
 
83
 
84
  image = Image.fromarray(image)
85
  image.save(INPUT_DIR + '/input.png', format='PNG')
@@ -132,7 +136,10 @@ def generate_image(image):
132
  if __name__ == "__main__":
133
  demo = gr.Interface(
134
  fn=generate_image,
135
- inputs=[gr.Image(image_mode='RGBA', type="numpy")],
 
 
 
136
  outputs=[gr.Image(type="numpy", image_mode='RGBA')],
137
  title="Image Upscaler",
138
  description="BEST UPSCALER EVER!!!!!"
 
75
  return False
76
 
77
  @spaces.GPU(duration=170)
78
+ def generate_image(prompt, image):
79
  prefix_filename = str(random.randint(0, 999999))
80
+ try:
81
+ prompt = prompt.replace('ComfyUI', prefix_filename)
82
+ prompt = json.loads(prompt)
83
+ except:
84
+ prompt = read_prompt_from_file('config.json')
85
+ prompt = json.dumps(prompt, ensure_ascii=False).replace('output_image', prefix_filename)
86
+ prompt = json.loads(prompt)
87
 
88
  image = Image.fromarray(image)
89
  image.save(INPUT_DIR + '/input.png', format='PNG')
 
136
  if __name__ == "__main__":
137
  demo = gr.Interface(
138
  fn=generate_image,
139
+ inputs=[
140
+ "text",
141
+ gr.Image(image_mode='RGBA', type="numpy")
142
+ ],
143
  outputs=[gr.Image(type="numpy", image_mode='RGBA')],
144
  title="Image Upscaler",
145
  description="BEST UPSCALER EVER!!!!!"