tennyson commited on
Commit
a04699c
1 Parent(s): 87c8773
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -31,8 +31,18 @@ def read_content(file_path: str) -> str:
31
  return content
32
 
33
  def predict(dict, reference, scale, seed, step):
34
- init_image = dict["image"].convert("RGB").resize((512,512))
35
- mask = dict["mask"].convert("RGB").resize((512,512))
 
 
 
 
 
 
 
 
 
 
36
  generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
37
  output = pipe(
38
  image=init_image,
@@ -118,13 +128,9 @@ with image_blocks as demo:
118
  full_width=True,
119
  )
120
  with gr.Group(elem_id="share-btn-container"):
121
- community_icon = gr.HTML(community_icon_html, visible=False)
122
- loading_icon = gr.HTML(loading_icon_html, visible=False)
123
- share_button = gr.Button("Share to community", elem_id="share-btn", visible=False).style(
124
- margin=False,
125
- rounded=(False, True, True, False),
126
- full_width=True,
127
- )
128
 
129
  with gr.Row():
130
  gr.Examples([
 
31
  return content
32
 
33
  def predict(dict, reference, scale, seed, step):
34
+ width,height=dict["image"].size
35
+ if width<height:
36
+ factor=width/512.0
37
+ width=512
38
+ height=int((height/factor)/8.0)*8
39
+
40
+ else:
41
+ factor=height/512.0
42
+ height=512
43
+ width=int((width/factor)/8.0)*8
44
+ init_image = dict["image"].convert("RGB").resize((width,height))
45
+ mask = dict["mask"].convert("RGB").resize((width,height))
46
  generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
47
  output = pipe(
48
  image=init_image,
 
128
  full_width=True,
129
  )
130
  with gr.Group(elem_id="share-btn-container"):
131
+ community_icon = gr.HTML(community_icon_html, visible=True)
132
+ loading_icon = gr.HTML(loading_icon_html, visible=True)
133
+ share_button = gr.Button("Share to community", elem_id="share-btn", visible=True)
 
 
 
 
134
 
135
  with gr.Row():
136
  gr.Examples([