LeeveWasTaken commited on
Commit
d30772e
Β·
verified Β·
1 Parent(s): 87d30d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -13
app.py CHANGED
@@ -1,8 +1,6 @@
1
  import gradio as gr
2
  from random import randint
3
  from all_models import models
4
- from PIL import Image
5
- import io
6
 
7
  def load_fn(models):
8
  global models_load
@@ -28,22 +26,13 @@ def update_imgbox(choices):
28
  choices_plus = extend_choices(choices)
29
  return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
30
 
31
- def save_image_as_jpg(image):
32
- if image:
33
- image = Image.open(io.BytesIO(image))
34
- img_byte_arr = io.BytesIO()
35
- image.save(img_byte_arr, format='JPEG')
36
- return img_byte_arr.getvalue()
37
- return None
38
-
39
  def gen_fn(model_str, prompt, negative_prompt=None, image_style="Default"):
40
  if model_str == 'NA':
41
  return None
42
  modified_prompt = f"{prompt}, {image_style}"
43
  if negative_prompt:
44
  modified_prompt += f", not {negative_prompt}"
45
- image = models_load[model_str](modified_prompt)
46
- return save_image_as_jpg(image)
47
 
48
  with gr.Blocks() as demo:
49
  with gr.Tab('The Dream'):
@@ -92,4 +81,4 @@ with gr.Blocks() as demo:
92
  """
93
  )
94
 
95
- demo.launch(max_threads=200)
 
1
  import gradio as gr
2
  from random import randint
3
  from all_models import models
 
 
4
 
5
  def load_fn(models):
6
  global models_load
 
26
  choices_plus = extend_choices(choices)
27
  return [gr.Image(None, label=m, visible=(m != 'NA')) for m in choices_plus]
28
 
 
 
 
 
 
 
 
 
29
  def gen_fn(model_str, prompt, negative_prompt=None, image_style="Default"):
30
  if model_str == 'NA':
31
  return None
32
  modified_prompt = f"{prompt}, {image_style}"
33
  if negative_prompt:
34
  modified_prompt += f", not {negative_prompt}"
35
+ return models_load[model_str](modified_prompt)
 
36
 
37
  with gr.Blocks() as demo:
38
  with gr.Tab('The Dream'):
 
81
  """
82
  )
83
 
84
+ demo.launch(max_threads=200)