RiverZ linoyts HF Staff commited on
Commit
923e3f9
·
verified ·
1 Parent(s): 215f06f

add imageslider (#7)

Browse files

- add imageslider (8704d39710b99a317fb547e509c9d19375ca466b)


Co-authored-by: Linoy Tsaban <[email protected]>

Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -74,7 +74,7 @@ def infer(edit_images,
74
  if randomize_seed:
75
  seed = random.randint(0, MAX_SEED)
76
 
77
- image = pipe(
78
  prompt=instruction,
79
  image=combined_image,
80
  mask_image=mask,
@@ -85,15 +85,15 @@ def infer(edit_images,
85
  generator=torch.Generator().manual_seed(seed),
86
  ).images[0]
87
 
88
- w,h = image.size
89
- image = image.crop((w//2, 0, w, h))
90
 
91
  os.makedirs(args.output_dir, exist_ok=True)
92
 
93
  index = len(os.listdir(args.output_dir))
94
- image.save(f"{args.output_dir}/result_{index}.png")
95
 
96
- return image, seed
97
 
98
  # 新增的示例,将元组转换为列表
99
  new_examples = [
@@ -135,7 +135,7 @@ For more details, check out our [Github Repository](https://github.com/River-Zha
135
  )
136
  run_button = gr.Button("Run")
137
  with gr.Column():
138
- result = gr.Image(label="Result", show_label=False)
139
  gr.Markdown("⚠️ If your edit didn't work as desired, **try again with another seed** ! <br> If you use our example, don't forget to uncheck the random seed option. Otherwise, it will still use a random seed.")
140
  with gr.Accordion("Advanced Settings", open=True):
141
 
 
74
  if randomize_seed:
75
  seed = random.randint(0, MAX_SEED)
76
 
77
+ output_image = pipe(
78
  prompt=instruction,
79
  image=combined_image,
80
  mask_image=mask,
 
85
  generator=torch.Generator().manual_seed(seed),
86
  ).images[0]
87
 
88
+ w,h = output_image.size
89
+ output_image = output_image.crop((w//2, 0, w, h))
90
 
91
  os.makedirs(args.output_dir, exist_ok=True)
92
 
93
  index = len(os.listdir(args.output_dir))
94
+ output_image.save(f"{args.output_dir}/result_{index}.png")
95
 
96
+ return (image, output_image), seed
97
 
98
  # 新增的示例,将元组转换为列表
99
  new_examples = [
 
135
  )
136
  run_button = gr.Button("Run")
137
  with gr.Column():
138
+ result = gr.ImageSlider(label="Result", show_label=False)
139
  gr.Markdown("⚠️ If your edit didn't work as desired, **try again with another seed** ! <br> If you use our example, don't forget to uncheck the random seed option. Otherwise, it will still use a random seed.")
140
  with gr.Accordion("Advanced Settings", open=True):
141