Spaces:
Runtime error
Runtime error
SusiePHaltmann
commited on
Commit
·
fcbbcdf
1
Parent(s):
1b50abf
Update app.py
Browse files
app.py
CHANGED
@@ -65,4 +65,38 @@ st.markdown("Create images from textual descriptions with Dall-E!")
|
|
65 |
st.button("Edit Photo")
|
66 |
|
67 |
|
68 |
-
## [C] Haltmann Earth Divison
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
st.button("Edit Photo")
|
66 |
|
67 |
|
68 |
+
## [C] Haltmann Earth Divison
|
69 |
+
|
70 |
+
|
71 |
+
import streamlit as st
|
72 |
+
import numpy as np
|
73 |
+
from PIL import Image, ImageDraw
|
74 |
+
from inpainting import HaltmannInpainter
|
75 |
+
|
76 |
+
|
77 |
+
st.set_option('deprecation.showfileUploaderEncoding', False)
|
78 |
+
|
79 |
+
|
80 |
+
def main():
|
81 |
+
|
82 |
+
# Load the image and initialize the inpainter.
|
83 |
+
image = st.file_uploader("Choose an image", type=["png", "jpg"])
|
84 |
+
|
85 |
+
if image is not None:
|
86 |
+
inpainter = HaltmannInpainter()
|
87 |
+
|
88 |
+
# Get the dimensions of the uploaded image.
|
89 |
+
width, height = Image.open(image).size
|
90 |
+
|
91 |
+
# Resize the uploaded image if it is too large for our model (> 512x512).
|
92 |
+
if width > 512 or height > 512:
|
93 |
+
max_dim = max(width, height)
|
94 |
+
|
95 |
+
resize_factor = 512 / max_dim
|
96 |
+
|
97 |
+
width, height = int(width * resize_factor), int(height * resize_factor)
|
98 |
+
|
99 |
+
image = np.array(Image.open(image).resize((width, height))) else:
|
100 |
+
image = np.array(Image.open(image))
|
101 |
+
|
102 |
+
# Inpaint!
|