Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -18,9 +18,11 @@ device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
| 18 |
model_name = {
|
| 19 |
"aurora": 'huggan/fastgan-few-shot-aurora',
|
| 20 |
"painting": 'huggan/fastgan-few-shot-painting',
|
| 21 |
-
#"painting":"geninhu/fastgan-few-shot-art",
|
| 22 |
"shell": 'huggan/fastgan-few-shot-shells',
|
| 23 |
"fauvism": 'huggan/fastgan-few-shot-fauvism-still-life',
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
#@st.cache(allow_output_mutation=True)
|
|
@@ -54,6 +56,34 @@ def load_lottieurl(url: str):
|
|
| 54 |
return None
|
| 55 |
return r.json()
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
def main():
|
| 59 |
|
|
@@ -91,36 +121,22 @@ def main():
|
|
| 91 |
)
|
| 92 |
|
| 93 |
st.header("Welcome to FastGAN")
|
|
|
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
st.
|
| 99 |
-
|
| 100 |
-
with col2:
|
| 101 |
-
st.markdown('Aurora GAN [model](https://huggingface.co/huggan/fastgan-few-shot-aurora-bs8)', unsafe_allow_html=True)
|
| 102 |
-
st.image('aurora.png', width=220)
|
| 103 |
-
|
| 104 |
-
with col3:
|
| 105 |
-
st.markdown('Painting GAN [model](https://huggingface.co/huggan/fastgan-few-shot-painting-bs8)', unsafe_allow_html=True)
|
| 106 |
-
st.image('painting.png', width=220)
|
| 107 |
-
with col4:
|
| 108 |
-
st.markdown('Shell GAN [model](https://huggingface.co/huggan/fastgan-few-shot-shells)', unsafe_allow_html=True)
|
| 109 |
-
st.image('shell.png', width=220)
|
| 110 |
-
|
| 111 |
-
st.markdown('___')
|
| 112 |
-
if st.checkbox('Click if you want to create one of your own !'):
|
| 113 |
-
|
| 114 |
-
col11, col12, col13 = st.columns([3,3.5,3.5])
|
| 115 |
with col11:
|
| 116 |
-
img_type = st.selectbox("Choose type of image to generate", index=0,
|
|
|
|
| 117 |
# with col12:
|
| 118 |
number_imgs = st.slider('How many images you want to generate ?', min_value=1, max_value=5)
|
| 119 |
if number_imgs is None:
|
| 120 |
st.write('Invalid number ! Please insert number of images to generate !')
|
| 121 |
raise ValueError('Invalid number ! Please insert number of images to generate !')
|
| 122 |
|
| 123 |
-
generate_button = st.button('Get Image
|
| 124 |
if generate_button:
|
| 125 |
st.markdown("""
|
| 126 |
<small><i>Predictions may take up to 1 minute under high load. Please stand by.</i></small>
|
|
|
|
| 18 |
model_name = {
|
| 19 |
"aurora": 'huggan/fastgan-few-shot-aurora',
|
| 20 |
"painting": 'huggan/fastgan-few-shot-painting',
|
|
|
|
| 21 |
"shell": 'huggan/fastgan-few-shot-shells',
|
| 22 |
"fauvism": 'huggan/fastgan-few-shot-fauvism-still-life',
|
| 23 |
+
"universe": 'huggan/fastgan-few-shot-universe',
|
| 24 |
+
"grumpy cat": 'huggan/fastgan-few-shot-grumpy-cat',
|
| 25 |
+
"anime": 'huggan/fastgan-few-shot-anime-face',
|
| 26 |
}
|
| 27 |
|
| 28 |
#@st.cache(allow_output_mutation=True)
|
|
|
|
| 56 |
return None
|
| 57 |
return r.json()
|
| 58 |
|
| 59 |
+
def show_model_summary(expanded):
|
| 60 |
+
with st.expander("Model gallery", expanded=expanded):
|
| 61 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 62 |
+
with col1:
|
| 63 |
+
st.markdown('Fauvism GAN [model](https://huggingface.co/huggan/fastgan-few-shot-fauvism-still-life)', unsafe_allow_html=True)
|
| 64 |
+
st.image('fauvism.png', width=200)
|
| 65 |
+
|
| 66 |
+
st.markdown('Painting GAN [model](https://huggingface.co/huggan/fastgan-few-shot-painting)', unsafe_allow_html=True)
|
| 67 |
+
st.image('painting.png', width=200)
|
| 68 |
+
|
| 69 |
+
with col2:
|
| 70 |
+
st.markdown('Aurora GAN [model](https://huggingface.co/huggan/fastgan-few-shot-aurora)', unsafe_allow_html=True)
|
| 71 |
+
st.image('aurora.png', width=200)
|
| 72 |
+
|
| 73 |
+
st.markdown('Universe GAN [model](https://huggingface.co/huggan/fastgan-few-shot-universe)', unsafe_allow_html=True)
|
| 74 |
+
st.image('universe.png', width=200)
|
| 75 |
+
|
| 76 |
+
with col3:
|
| 77 |
+
st.markdown('Anime GAN [model](https://huggingface.co/huggan/fastgan-few-shot-anime-face)', unsafe_allow_html=True)
|
| 78 |
+
st.image('anime.png', width=200)
|
| 79 |
+
|
| 80 |
+
st.markdown('Shell GAN [model](https://huggingface.co/huggan/fastgan-few-shot-shells)', unsafe_allow_html=True)
|
| 81 |
+
st.image('shell.png', width=200)
|
| 82 |
+
|
| 83 |
+
with col4:
|
| 84 |
+
st.markdown('Grumpy cat GAN [model](https://huggingface.co/huggan/fastgan-few-shot-grumpy-cat)', unsafe_allow_html=True)
|
| 85 |
+
st.image('grumpy_cat.png', width=200)
|
| 86 |
+
|
| 87 |
|
| 88 |
def main():
|
| 89 |
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
st.header("Welcome to FastGAN")
|
| 124 |
+
checked = st.checkbox('Click here if you want to create one of your own !')
|
| 125 |
|
| 126 |
+
if not checked:
|
| 127 |
+
show_model_summary(True)
|
| 128 |
+
if checked:
|
| 129 |
+
col11, col12, col13 = st.columns([2.9,3.05,3.05])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
with col11:
|
| 131 |
+
img_type = st.selectbox("Choose type of image to generate", index=0,
|
| 132 |
+
options=["aurora", "anime", "painting", "fauvism", "shell", "universe", "grumpy cat"])
|
| 133 |
# with col12:
|
| 134 |
number_imgs = st.slider('How many images you want to generate ?', min_value=1, max_value=5)
|
| 135 |
if number_imgs is None:
|
| 136 |
st.write('Invalid number ! Please insert number of images to generate !')
|
| 137 |
raise ValueError('Invalid number ! Please insert number of images to generate !')
|
| 138 |
|
| 139 |
+
generate_button = st.button('Get Image')
|
| 140 |
if generate_button:
|
| 141 |
st.markdown("""
|
| 142 |
<small><i>Predictions may take up to 1 minute under high load. Please stand by.</i></small>
|