multimodalart HF Staff commited on
Commit
4eb0678
·
verified ·
1 Parent(s): ab1f7ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  import spaces
4
  from diffusers import FluxInpaintPipeline
5
  from PIL import Image, ImageFile
 
6
 
7
  #ImageFile.LOAD_TRUNCATED_IMAGES = True
8
 
@@ -36,11 +37,13 @@ def duplicate_horizontally(img):
36
  width, height = img.size
37
  if width != height:
38
  raise ValueError(f"Input image must be square, got {width}x{height}")
39
-
40
- new_image = Image.new('RGB', (width * 2, height))
41
- new_image.paste(img, (0, 0))
42
- #new_image.paste(img, (width, 0))
43
- return new_image
 
 
44
 
45
  # Load the mask image
46
  mask = Image.open("mask_square.png")
@@ -81,7 +84,7 @@ with gr.Blocks() as demo:
81
  with gr.Column():
82
  input_image = gr.Image(
83
  label="Upload Logo Image",
84
- type="pil",
85
  height=384
86
  )
87
  cropped_image = gr.Image(
 
3
  import spaces
4
  from diffusers import FluxInpaintPipeline
5
  from PIL import Image, ImageFile
6
+ import numpy as np
7
 
8
  #ImageFile.LOAD_TRUNCATED_IMAGES = True
9
 
 
37
  width, height = img.size
38
  if width != height:
39
  raise ValueError(f"Input image must be square, got {width}x{height}")
40
+
41
+ # Convert to numpy array
42
+ img_array = np.array(img)
43
+ # Stack horizontally
44
+ duplicated = np.hstack((img_array, img_array))
45
+ # Convert back to PIL Image
46
+ return Image.fromarray(duplicated)
47
 
48
  # Load the mask image
49
  mask = Image.open("mask_square.png")
 
84
  with gr.Column():
85
  input_image = gr.Image(
86
  label="Upload Logo Image",
87
+ type="numpy",
88
  height=384
89
  )
90
  cropped_image = gr.Image(