Spaces:
Runtime error
Runtime error
import streamlit as st | |
import numpy as np | |
from PIL import Image | |
def main(): | |
st.title("Haltmann Diffusion Algorithm") | |
slider = st.slider("Slider", 0, 255, 128) # default value=128, min=0, max=255 | |
st.title("Haltmann Diffusion Algorithm [C] 20XX ") | |
import streamlit as st | |
from PIL import Image | |
import numpy as np | |
st.text("This app generates VQ-GAN prompts for generating inpaintings.") | |
st.text("To use this app, simply enter the desired text prompt and hit generate.") | |
# This decorator ensures that the function only runs once per session. Otherwise, each time we generate a prompt, it would run again! This is important because we don't want to keep re-generating prompts unnecessarily. We only want to generate a new prompt when the user enters a new one. If we didn't cache this function, each time we generated a new prompt, it would also regenerate all of the previous prompts! Caching is an important concept in Streamlit apps - it can help make your apps much more efficient by avoiding unnecessary computations. | |
def generate_prompt(text): # This is the function that actually generates our VQ-GAN prompt It takes in a string (the text prompt) and outputs another string (the generated VQ-GAN prompt). We'll use this function to actually generate our VQ-GAN prompts when the user hits "Generate". | |
return "Enter text here" + text + "and hit generate!" | |
st.write(generate_prompt("")) # We start by writing an empty string - this will be replaced with our generated prompt when the user hits "Generate" | |
def inpaint(img, mask): | |
"""Inpaints the given image using the given mask. | |
Args: | |
img: The image to inpaint. Must be a 3-channel RGB image. | |
mask: The inpainting mask. Must be a binary 3-channel image | |
with 1s indicating the area to inpaint and 0s indicating | |
the area to leave unchanged. | |
Returns: | |
The inpainted image as a 3-channel RGB numpy array. """ | |
## V0.2 | |
import streamlit as st | |
import numpy as np | |
from PIL import Image | |
import requests | |
import io | |
st.set_option('deprecation.showfileUploaderEncoding', False) | |
def load_image(img): | |
im = Image.open(img) | |
return im | |
def main(): | |
st.title("Dall-E Patrya ") | |
uploaded_file = st.file_uploader("Choose an image", type="jpg") | |
st.markdown("Create images from textual descriptions with Dall-PFT!") | |
st.button("Edit Photo") | |
import streamlit as st | |
st.title("VQGAN Inpainting App") | |
st.markdown("This app uses a pre-trained VQGAN model to inpaint images.") | |
def load_model(): | |
# Load the pre-trained VQGAN model | |
return vqgan.load_model('vqgan') | |
def inpaint(img, model, coords): | |
# Inpaint the selected region of the image using the VQGAN model | |
inpainted = vqgan.inpaint(img, model, coords) | |
return inpainted | |
## [C] Haltmann Earth Divison [C] - 20XX | |
import streamlit as st | |
from PIL import Image, ImageOps | |
import numpy as np | |
def inpaint(image, mask): | |
"""Inpaints the given image using the Mask.""" | |
# Convert to float32 before passing to cv2.inpaint() function. Otherwise it returns a distorted output. | |
img = np.float32(image) | |
dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA) | |