SusiePHaltmann commited on
Commit
6c65253
1 Parent(s): 06694e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -15,8 +15,21 @@ import streamlit as st
15
  from PIL import Image
16
 
17
  import numpy as np
 
 
 
18
 
19
 
 
 
 
 
 
 
 
 
 
 
20
  def inpaint(img, mask):
21
 
22
  """Inpaints the given image using the given mask.
 
15
  from PIL import Image
16
 
17
  import numpy as np
18
+ st.title("VQ-GAN Prompt Generator")
19
+ st.text("This app generates VQ-GAN prompts for generating inpaintings.")
20
+ st.text("To use this app, simply enter the desired text prompt and hit generate.")
21
 
22
 
23
+ @st.cache(allow_output_mutation=True) # 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.
24
+
25
+ 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".
26
+
27
+ return "Enter text here" + text + "and hit generate!"
28
+
29
+ if __name__ == '__main__': # This block of code is what actually runs our Streamlit app When you run `streamlit run app.py` in your terminal, this is what will get executed!
30
+
31
+ st.write(generate_prompt("")) # We start by writing an empty string - this will be replaced with our generated prompt when the user hits "Generate"
32
+
33
  def inpaint(img, mask):
34
 
35
  """Inpaints the given image using the given mask.