push app
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import numpy as np
|
| 3 |
import streamlit as st
|
| 4 |
-
from PIL import Image, ImageDraw
|
| 5 |
import numpy as np
|
| 6 |
import torch
|
| 7 |
|
|
@@ -23,7 +23,7 @@ FASTSAM_CHECKPOINT = "FastSAM-x.pt" # file name of the FastSAM model weights
|
|
| 23 |
SD_MODEL_ID = "runwayml/stable-diffusion-inpainting" # HF Hub model for SD Inpainting v1.5
|
| 24 |
|
| 25 |
# Helper function: center crop and resize to 768x512 (landscape)
|
| 26 |
-
def crop_resize_image(image, target_width=
|
| 27 |
desired_ratio = target_width / target_height # 768/512 = 1.5
|
| 28 |
width, height = image.size
|
| 29 |
current_ratio = width / height
|
|
@@ -100,7 +100,7 @@ if "img" not in st.session_state:
|
|
| 100 |
picture = st.camera_input("Take a picture", disabled=not enable)
|
| 101 |
if picture is not None:
|
| 102 |
img = Image.open(picture)
|
| 103 |
-
img = crop_resize_image(img, target_width=
|
| 104 |
st.session_state.img = img
|
| 105 |
# Reset coordinates list on new capture
|
| 106 |
st.session_state.coords_list = []
|
|
|
|
| 1 |
import os
|
| 2 |
import numpy as np
|
| 3 |
import streamlit as st
|
| 4 |
+
from PIL import Image, ImageDraw, ImageFilter
|
| 5 |
import numpy as np
|
| 6 |
import torch
|
| 7 |
|
|
|
|
| 23 |
SD_MODEL_ID = "runwayml/stable-diffusion-inpainting" # HF Hub model for SD Inpainting v1.5
|
| 24 |
|
| 25 |
# Helper function: center crop and resize to 768x512 (landscape)
|
| 26 |
+
def crop_resize_image(image, target_width=480, target_height=640):
|
| 27 |
desired_ratio = target_width / target_height # 768/512 = 1.5
|
| 28 |
width, height = image.size
|
| 29 |
current_ratio = width / height
|
|
|
|
| 100 |
picture = st.camera_input("Take a picture", disabled=not enable)
|
| 101 |
if picture is not None:
|
| 102 |
img = Image.open(picture)
|
| 103 |
+
img = crop_resize_image(img, target_width=480, target_height=640)
|
| 104 |
st.session_state.img = img
|
| 105 |
# Reset coordinates list on new capture
|
| 106 |
st.session_state.coords_list = []
|