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 st.write("Welcome! Please wait ?? years for the ai to be done.") import streamlit as st st.markdown("Welcome! Please wait ?? years for the ai to be done.") import streamlit as st from PIL import Image import numpy as np 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) @st.cache(allow_output_mutation=True) def load_image(img): im = Image.open(img) return im def main(): st.title("Dall-E Flow") uploaded_file = st.file_uploader("Choose an image", type="jpg") if uploaded_file is not None: # if user has uploaded file, display it in the app UI # along with the option to edit it # (i.e., erase portions of the image using a brush tool) # or download it after editing is complete img = load_image(uploaded_file) st.image(img, caption='Original Image', use_column_width=True) # create "Erase" button and erase brush size slider erase = st.button('Erase') brushsize = st.slider('Brush Size', 0, 100, 5, key='brush') # create "Download" button and hide it by default download = st.button('Download') download = download if not erase else None # define functions for handling mouse events def onclick(x, y): draw[int(y)-brushsize:int(y)+brushsize+1, int(x)-brushsize:int(x)+brushsize+1] \ *= 0 def ondragstart(): pass def ondragmove(): pass def ondragend(): pass # set up event handlers for when "Erase" button is clicked if erase: draw = img._numpy().copy() width, height = draw[:, :3].shape[1:] xylims=(0., width), (0., height) figtoolbar=dict(_visible=False), _onclick=onclick, _ondragstart=ondragstart(), _ondragmove=ondragmove(), _ondragend=ondragend()) pxsz=(width/height)/100*5 pltlytools="boxselect", "lassoselect", "pan", "wheelzoom", "reset" figkwargs={'layout': go .Layout(*figtoolbar)} with out: clear() show(*pltlytools)(draw[:, :3], **figkwargs)) elif download: return sendfiles([BytesIO((255*draw).astype('uint8'))], [f'dall-e-{time()}.png']) else: return None main()