itberrios commited on
Commit
53e96bd
·
1 Parent(s): 68a78ac
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -1,22 +1,22 @@
1
  import streamlit as st
2
  from PIL import Image
3
 
4
- # import torch
5
- # from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
6
- # from diffusers import StableDiffusionInpaintPipeline
7
 
8
 
9
- # device = 'cuda' if torch.cuda.is_available() else 'cpu'
10
 
11
- # seg_processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
12
- # seg_model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
13
 
14
 
15
- # # get Stable Diffusion model for image inpainting
16
- # pipe = StableDiffusionInpaintPipeline.from_pretrained(
17
- # "runwayml/stable-diffusion-inpainting",
18
- # torch_dtype=torch.float16,
19
- # ).to(device)
20
 
21
 
22
  st.title("Stable Edit - Edit your photos with Stable Diffusion!")
@@ -27,7 +27,7 @@ image = Image.open(filename)
27
  st.image(image)
28
 
29
  # Select Area to edit
30
- st.selectbox("Options", ("AutoSegment Area", "Draw Custom Area"))
31
 
32
  # TEMP - DEMO stuff
33
  x = st.slider('Select a value')
 
1
  import streamlit as st
2
  from PIL import Image
3
 
4
+ import torch
5
+ from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
6
+ from diffusers import StableDiffusionInpaintPipeline
7
 
8
 
9
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
10
 
11
+ seg_processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
12
+ seg_model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
13
 
14
 
15
+ # get Stable Diffusion model for image inpainting
16
+ pipe = StableDiffusionInpaintPipeline.from_pretrained(
17
+ "runwayml/stable-diffusion-inpainting",
18
+ torch_dtype=torch.float16,
19
+ ).to(device)
20
 
21
 
22
  st.title("Stable Edit - Edit your photos with Stable Diffusion!")
 
27
  st.image(image)
28
 
29
  # Select Area to edit
30
+ selection = st.selectbox("Select Area(s) to edit", ("AutoSegment Area", "Draw Custom Area", "Suprise Me"))
31
 
32
  # TEMP - DEMO stuff
33
  x = st.slider('Select a value')