ovshake commited on
Commit
5664062
1 Parent(s): 45f2f99

making load model efficient

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -73,7 +73,7 @@ def process_image(args, inpainting_pipeline, net):
73
  transforms_list += [transforms.ToTensor()]
74
  transforms_list += [Normalize_image(0.5, 0.5)]
75
  transform_rgb = transforms.Compose(transforms_list)
76
- # img = Image.open(image_path)
77
  img = img.convert("RGB")
78
  img = img.resize((args.resolution, args.resolution))
79
  if args.rembg:
@@ -107,16 +107,15 @@ def process_image(args, inpainting_pipeline, net):
107
  clothed_image_from_pipeline = change_bg_color(clothed_image_from_pipeline, "WHITE")
108
  return clothed_image_from_pipeline.convert("RGB")
109
 
110
-
111
- st.title("Stable Fashion Huggingface Spaces")
112
- file_name = st.file_uploader("Upload a clear full length picture of yourself, preferably in a less noisy background")
113
  net = load_u2net()
114
  inpainting_pipeline = load_inpainting_pipeline()
 
 
 
115
 
116
  if file_name is not None:
117
- image = Image.open(file_name)
118
  stable_fashion_args = StableFashionCLIArgs()
119
- stable_fashion_args.image = image
120
  body_part = st.radio("Would you like to try clothes on your upper body (such as shirts, kurtas etc) or lower (Jeans, Pants etc)? ", ('Upper', 'Lower'))
121
  stable_fashion_args.part = body_part
122
  resolution = st.radio("Which resolution would you like to get the resulting picture in? (Keep in mind, higher the resolution, higher the queue times)", (128, 256, 512))
@@ -132,7 +131,7 @@ if file_name is not None:
132
 
133
 
134
  result_image = process_image(stable_fashion_args, inpainting_pipeline, net)
135
- st.image(result_image, caption='Sunrise by the mountains')
136
 
137
 
138
 
 
73
  transforms_list += [transforms.ToTensor()]
74
  transforms_list += [Normalize_image(0.5, 0.5)]
75
  transform_rgb = transforms.Compose(transforms_list)
76
+ img = Image.open(image_path)
77
  img = img.convert("RGB")
78
  img = img.resize((args.resolution, args.resolution))
79
  if args.rembg:
 
107
  clothed_image_from_pipeline = change_bg_color(clothed_image_from_pipeline, "WHITE")
108
  return clothed_image_from_pipeline.convert("RGB")
109
 
 
 
 
110
  net = load_u2net()
111
  inpainting_pipeline = load_inpainting_pipeline()
112
+ st.title("Stable Fashion Huggingface Spaces")
113
+ file_name = st.file_uploader("Upload a clear full length picture of yourself, preferably in a less noisy background")
114
+
115
 
116
  if file_name is not None:
 
117
  stable_fashion_args = StableFashionCLIArgs()
118
+ stable_fashion_args.image = file_name
119
  body_part = st.radio("Would you like to try clothes on your upper body (such as shirts, kurtas etc) or lower (Jeans, Pants etc)? ", ('Upper', 'Lower'))
120
  stable_fashion_args.part = body_part
121
  resolution = st.radio("Which resolution would you like to get the resulting picture in? (Keep in mind, higher the resolution, higher the queue times)", (128, 256, 512))
 
131
 
132
 
133
  result_image = process_image(stable_fashion_args, inpainting_pipeline, net)
134
+ st.image(result_image, caption='Result')
135
 
136
 
137