itberrios commited on
Commit
0ae24ac
·
1 Parent(s): 956315a
Files changed (3) hide show
  1. __pycache__/model.cpython-310.pyc +0 -0
  2. app.py +7 -5
  3. model.py +1 -1
__pycache__/model.cpython-310.pyc ADDED
Binary file (2.02 kB). View file
 
app.py CHANGED
@@ -45,8 +45,6 @@ def get_mask_from_rectangles(image, mask, height, width, drawing_mode='rect'):
45
  objects[col] = objects[col].astype("str")
46
 
47
  if len(objects) > 0:
48
- # st.dataframe(objects)
49
-
50
  left_coords = objects.left.to_numpy()
51
  top_coords = objects.top.to_numpy()
52
  right_coords = left_coords + objects.width.to_numpy()
@@ -75,7 +73,6 @@ def get_mask(image, edit_method, height, width):
75
  viridis = mpl.colormaps.get_cmap('viridis').resampled(np.max(seg))
76
  seg_image = Image.fromarray(np.uint8(viridis(seg)*255))
77
 
78
- # display image
79
  st.image(seg_image)
80
 
81
  # prompt user to select valid labels to edit
@@ -103,7 +100,6 @@ if __name__ == '__main__':
103
 
104
  # upload image
105
  filename = st.file_uploader("upload an image")
106
- # filename = r"C:\Users\itber\Downloads\Fjord_Cycling.jpg"
107
 
108
  sf = st.text_input("Please enter resizing scale factor to downsize image (default = 2)", value="2")
109
  try:
@@ -130,10 +126,16 @@ if __name__ == '__main__':
130
 
131
  # get inpainted images
132
  prompt = st.text_input("Please enter prompt for image inpainting", value="")
 
 
 
 
 
 
133
 
134
  st.write("Inpainting Images, patience is a virtue :)")
135
 
136
- images = inpaint(image, mask, width, height, prompt=prompt, seed=0, guidance_scale=17.5, num_samples=3)
137
 
138
  # display all images
139
  st.write("Original Image")
 
45
  objects[col] = objects[col].astype("str")
46
 
47
  if len(objects) > 0:
 
 
48
  left_coords = objects.left.to_numpy()
49
  top_coords = objects.top.to_numpy()
50
  right_coords = left_coords + objects.width.to_numpy()
 
73
  viridis = mpl.colormaps.get_cmap('viridis').resampled(np.max(seg))
74
  seg_image = Image.fromarray(np.uint8(viridis(seg)*255))
75
 
 
76
  st.image(seg_image)
77
 
78
  # prompt user to select valid labels to edit
 
100
 
101
  # upload image
102
  filename = st.file_uploader("upload an image")
 
103
 
104
  sf = st.text_input("Please enter resizing scale factor to downsize image (default = 2)", value="2")
105
  try:
 
126
 
127
  # get inpainted images
128
  prompt = st.text_input("Please enter prompt for image inpainting", value="")
129
+ seed = st.text_input("(Optional) enter seed to change inpainting result (default=0)", value="0")
130
+ try:
131
+ seed = int(seed)
132
+ except:
133
+ st.write("Invalid seed! Defaultign to 0, please re-enter above to change it")
134
+ seed = 0
135
 
136
  st.write("Inpainting Images, patience is a virtue :)")
137
 
138
+ images = inpaint(image, mask, width, height, prompt=prompt, seed=seed, guidance_scale=17.5, num_samples=3)
139
 
140
  # display all images
141
  st.write("Original Image")
model.py CHANGED
@@ -50,7 +50,7 @@ def inpaint(image, mask, W, H, prompt="", seed=0, guidance_scale=17.5, num_sampl
50
  Outputs:
51
  images - output images
52
  """
53
- generator = torch.Generator(device="cuda").manual_seed(seed)
54
  images = pipe(
55
  prompt=prompt,
56
  image=image,
 
50
  Outputs:
51
  images - output images
52
  """
53
+ generator = torch.Generator(device=device).manual_seed(seed)
54
  images = pipe(
55
  prompt=prompt,
56
  image=image,