francescoKrnl commited on
Commit
5164e6e
1 Parent(s): 4945af7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -38,7 +38,6 @@ def run(image, item_name):
38
  prompt = item_name + " professional 3d model. octane render, highly detailed, volumetric, dramatic lighting"
39
  image = image.convert("RGB")
40
  image_t = TF.to_tensor(image) > 0.5
41
- image_pil = TF.to_pil_image(image_t.to(torch.float32))
42
  with torch.no_grad():
43
  c_t = image_t.unsqueeze(0).cuda().float()
44
  torch.manual_seed(42)
@@ -46,9 +45,7 @@ def run(image, item_name):
46
  noise = torch.randn((1,4,H//8, W//8), device=c_t.device)
47
  output_image = model(c_t, prompt, deterministic=False, r=0.4, noise_map=noise)
48
  output_pil = TF.to_pil_image(output_image[0].cpu()*0.5+0.5)
49
- input_sketch_uri = pil_image_to_data_uri(Image.fromarray(255-np.array(image)))
50
- output_image_uri = pil_image_to_data_uri(output_pil)
51
- return output_pil, gr.update(link=input_sketch_uri), gr.update(link=output_image_uri)
52
 
53
 
54
  def update_canvas(use_line, use_eraser):
@@ -164,10 +161,10 @@ async () => {
164
 
165
  with gr.Blocks(css="style.css") as demo:
166
  # these are hidden buttons that are used to trigger the canvas changes
167
- line = gr.Checkbox(label="line", value=False, elem_id="cb-line")
168
- eraser = gr.Checkbox(label="eraser", value=False, elem_id="cb-eraser")
169
- with gr.Row(elem_id="header_block"):
170
- gr.HTML("""<img src="file=assets/title.png" alt="title" /><img src="file=assets/logos.png" alt="title" />""")
171
  with gr.Column(elem_id="main_block"):
172
  with gr.Row(elem_id="board_row"):
173
  with gr.Group(elem_id="input_image_container", elem_classes="image_container" ):
@@ -183,8 +180,9 @@ with gr.Blocks(css="style.css") as demo:
183
  result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
184
  with gr.Row(elem_id="radio_row"):
185
  item = gr.Radio(choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME)
186
- with gr.Row(elem_id="footer_block"):
187
- gr.HTML("""<button id="fullscreen" onclick="document.body.querySelector('#main_row').requestFullscreen();" class="fullscreen" title="fullscreen"></button>""")
 
188
 
189
  demo.load(None,None,None,_js=scripts)
190
  inputs = [image, item]
 
38
  prompt = item_name + " professional 3d model. octane render, highly detailed, volumetric, dramatic lighting"
39
  image = image.convert("RGB")
40
  image_t = TF.to_tensor(image) > 0.5
 
41
  with torch.no_grad():
42
  c_t = image_t.unsqueeze(0).cuda().float()
43
  torch.manual_seed(42)
 
45
  noise = torch.randn((1,4,H//8, W//8), device=c_t.device)
46
  output_image = model(c_t, prompt, deterministic=False, r=0.4, noise_map=noise)
47
  output_pil = TF.to_pil_image(output_image[0].cpu()*0.5+0.5)
48
+ return output_pil
 
 
49
 
50
 
51
  def update_canvas(use_line, use_eraser):
 
161
 
162
  with gr.Blocks(css="style.css") as demo:
163
  # these are hidden buttons that are used to trigger the canvas changes
164
+ gr.HTML("""<div id="header_block">
165
+ <img src="file=assets/title.png" alt="title" />
166
+ <img src="file=assets/logos.png" alt="title" />
167
+ </div>""")
168
  with gr.Column(elem_id="main_block"):
169
  with gr.Row(elem_id="board_row"):
170
  with gr.Group(elem_id="input_image_container", elem_classes="image_container" ):
 
180
  result = gr.Image(label="Result", height=440, width=440, elem_id="output_image", show_label=False, show_download_button=True)
181
  with gr.Row(elem_id="radio_row"):
182
  item = gr.Radio(choices=ITEMS_NAMES, value=DEFAULT_ITEM_NAME)
183
+ gr.HTML("""<div id="footer_block">
184
+ <button id="fullscreen" onclick="document.body.querySelector('#main_row').requestFullscreen();" class="fullscreen" title="fullscreen"></button>
185
+ </div>""")
186
 
187
  demo.load(None,None,None,_js=scripts)
188
  inputs = [image, item]