yonishafir commited on
Commit
9ec628d
1 Parent(s): 05f76db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -78,7 +78,6 @@ def get_size(init_image):
78
 
79
  device = "cuda" if torch.cuda.is_available() else "cpu"
80
 
81
-
82
  # Load, init model
83
  controlnet = ControlNetModel().from_pretrained("briaai/DEV-ControlNetInpaintingFast", torch_dtype=torch.float16)
84
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
@@ -96,10 +95,6 @@ generator = torch.Generator(device='cuda').manual_seed(123456)
96
  vae = pipe.vae
97
 
98
  pipe.enable_model_cpu_offload()
99
- # pipe.force_zeros_for_empty_prompt = False
100
-
101
- # default_negative_prompt= "" #"Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
102
-
103
 
104
  def read_content(file_path: str) -> str:
105
  """read the content of target file
@@ -113,21 +108,14 @@ def predict(dict, prompt="", negative_prompt = default_negative_prompt, guidance
113
  if negative_prompt == "":
114
  negative_prompt = None
115
 
116
-
117
- # init_image = dict["image"].convert("RGB").resize((1024, 1024))
118
- # mask = dict["mask"].convert("L").resize((1024, 1024))
119
 
120
  width, height = get_size(init_image)
121
 
122
  init_image = init_image.resize((width, height))
123
  mask = mask.resize((width, height))
124
 
125
- # Resize to nearest ratio ?
126
-
127
- # mask = np.array(mask)
128
- # mask[mask>0]=255
129
- # mask = Image.fromarray(mask)
130
-
131
 
132
  masked_image, image_mask, masked_image_to_present = get_masked_image(init_image, mask, width, height)
133
  masked_image_tensor = image_transforms(masked_image)
 
78
 
79
  device = "cuda" if torch.cuda.is_available() else "cpu"
80
 
 
81
  # Load, init model
82
  controlnet = ControlNetModel().from_pretrained("briaai/DEV-ControlNetInpaintingFast", torch_dtype=torch.float16)
83
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
 
95
  vae = pipe.vae
96
 
97
  pipe.enable_model_cpu_offload()
 
 
 
 
98
 
99
  def read_content(file_path: str) -> str:
100
  """read the content of target file
 
108
  if negative_prompt == "":
109
  negative_prompt = None
110
 
111
+ init_image = dict["image"].convert("RGB")#.resize((1024, 1024))
112
+ mask = dict["mask"].convert("L")#.resize((1024, 1024))
 
113
 
114
  width, height = get_size(init_image)
115
 
116
  init_image = init_image.resize((width, height))
117
  mask = mask.resize((width, height))
118
 
 
 
 
 
 
 
119
 
120
  masked_image, image_mask, masked_image_to_present = get_masked_image(init_image, mask, width, height)
121
  masked_image_tensor = image_transforms(masked_image)