ciover2024 commited on
Commit
8fa0841
·
verified ·
1 Parent(s): 0088107

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import gradio as gr
2
  from PIL import Image
3
  import torch
4
- import torch.nn.functional as F
5
- import torchvision
6
- import torchvision.transforms as T
7
  from diffusers import StableDiffusionInpaintPipeline
8
  import numpy as np
9
- import cv2
10
  import os
11
  import shutil
12
  from gradio_client import Client, handle_file
@@ -27,11 +27,11 @@ inpaint_pipeline = load_inpainting_model()
27
 
28
  # Function to resize image (simpler interpolation method for speed)
29
  def resize_to_match(input_image, output_image):
30
- torch_img = pil_to_torch(input_image)
31
- torch_img_scaled = F.interpolate(torch_img.unsqueeze(0),mode='trilinear').squeeze(0)
32
- output_image = torchvision.transforms.functional.to_pil_image(torch_img_scaled, mode=None)
33
- return output_image
34
- #return output_image.resize(input_image.size, Image.BICUBIC) # Use BILINEAR for faster resizing
35
 
36
  # Function to generate the mask using Florence SAM Masking API (Replicate)
37
  def generate_mask(image_path, text_prompt="clothing"):
 
1
  import gradio as gr
2
  from PIL import Image
3
  import torch
4
+ #import torch.nn.functional as F
5
+ #import torchvision
6
+ #import torchvision.transforms as T
7
  from diffusers import StableDiffusionInpaintPipeline
8
  import numpy as np
9
+ #import cv2
10
  import os
11
  import shutil
12
  from gradio_client import Client, handle_file
 
27
 
28
  # Function to resize image (simpler interpolation method for speed)
29
  def resize_to_match(input_image, output_image):
30
+ #torch_img = pil_to_torch(input_image)
31
+ #torch_img_scaled = F.interpolate(torch_img.unsqueeze(0),mode='trilinear').squeeze(0)
32
+ #output_image = torchvision.transforms.functional.to_pil_image(torch_img_scaled, mode=None)
33
+ #return output_image
34
+ return output_image.resize(input_image.size, Image.BICUBIC) # Use BILINEAR for faster resizing
35
 
36
  # Function to generate the mask using Florence SAM Masking API (Replicate)
37
  def generate_mask(image_path, text_prompt="clothing"):