SusiePHaltmann commited on
Commit
da1c5b6
·
1 Parent(s): fb51992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -66,4 +66,4 @@ def main():
66
 
67
  uploaded_file = st.file_uploader("Choose an image", type="jpg")
68
 
69
- 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()
 
66
 
67
  uploaded_file = st.file_uploader("Choose an image", type="jpg")
68
 
69
+