Omnibus commited on
Commit
8a23d91
1 Parent(s): 5858c5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -14
app.py CHANGED
@@ -30,7 +30,7 @@ def run_dif(prompt,im_path,model_drop,cnt):
30
  url = base_url+im_path
31
  init_image = load_image(url)
32
 
33
- prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
34
 
35
  # pass prompt and image to pipeline
36
  #image = pipeline(prompt, image=init_image, strength=0.8,guidance_scale=8.0,negative_prompt=negative_prompt,num_inference_steps=50).images[0]
@@ -130,18 +130,6 @@ def thread_dif(out_prompt,mod):
130
  return out_box,html_out
131
 
132
 
133
-
134
- def start_threads(prompt):
135
- t1 = threading.Thread(target=thread_dif, args=(prompt,0))
136
- t2 = threading.Thread(target=thread_dif, args=(prompt,1))
137
- t1.start()
138
- t2.start()
139
- print (t1)
140
- print (t2)
141
- a1,a2=t1.result()
142
- b1,b2=t2.result()
143
- return a1,a2
144
-
145
  css="""
146
  .grid_class{
147
  display:flex;
@@ -152,16 +140,43 @@ min-width:200px;
152
  }
153
 
154
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  with gr.Blocks(css=css) as app:
156
  with gr.Row():
157
  with gr.Column():
158
  inp=gr.Textbox(label="Prompt")
159
  btn=gr.Button()
160
- inp_im=gr.Image(type='filepath')
 
 
161
  with gr.Row():
162
  model_drop=gr.Dropdown(label="Models", choices=models, type='index', value=models[0])
163
  cnt = gr.Number(value=1)
164
  out_html=gr.HTML()
165
  outp=gr.Gallery()
 
 
166
  btn.click(run_dif,[inp,inp_im,model_drop,cnt],[outp,out_html])
167
  app.launch()
 
30
  url = base_url+im_path
31
  init_image = load_image(url)
32
 
33
+ #prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
34
 
35
  # pass prompt and image to pipeline
36
  #image = pipeline(prompt, image=init_image, strength=0.8,guidance_scale=8.0,negative_prompt=negative_prompt,num_inference_steps=50).images[0]
 
130
  return out_box,html_out
131
 
132
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  css="""
134
  .grid_class{
135
  display:flex;
 
140
  }
141
 
142
  """
143
+
144
+ def load_im(img):
145
+ im_box=[]
146
+ im = Image.open(img)
147
+ width, height = im.size
148
+ new_w=int(width/10)
149
+ new_h=int(height/10)
150
+
151
+
152
+
153
+ # Setting the points for cropped image
154
+ left = 0
155
+ top = 0
156
+ right = new_w
157
+ bottom = new_h
158
+
159
+ # Cropped image of above dimension
160
+ # (It will not change original image)
161
+ im1 = im.crop((left, top, right, bottom))
162
+ im_box.append(im1)
163
+ return im_box
164
+
165
+
166
  with gr.Blocks(css=css) as app:
167
  with gr.Row():
168
  with gr.Column():
169
  inp=gr.Textbox(label="Prompt")
170
  btn=gr.Button()
171
+ with gr.Column():
172
+ inp_im=gr.Image(type='filepath')
173
+ im_btn=gr.Button()
174
  with gr.Row():
175
  model_drop=gr.Dropdown(label="Models", choices=models, type='index', value=models[0])
176
  cnt = gr.Number(value=1)
177
  out_html=gr.HTML()
178
  outp=gr.Gallery()
179
+
180
+ im_btn.click(load_im,inp_im,outp)
181
  btn.click(run_dif,[inp,inp_im,model_drop,cnt],[outp,out_html])
182
  app.launch()