Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ model_name = {
|
|
| 26 |
def load_generator(model_name_or_path):
|
| 27 |
generator = Generator(in_channels=256, out_channels=3)
|
| 28 |
generator = generator.from_pretrained(model_name_or_path, in_channels=256, out_channels=3)
|
| 29 |
-
_ = generator.to(
|
| 30 |
_ = generator.eval()
|
| 31 |
|
| 32 |
return generator
|
|
@@ -94,18 +94,18 @@ def main():
|
|
| 94 |
col1, col2, col3, col4 = st.columns([3,3,3,3])
|
| 95 |
with col1:
|
| 96 |
st.markdown('Fauvism GAN [model](https://huggingface.co/huggan/fastgan-few-shot-fauvism-still-life)', unsafe_allow_html=True)
|
| 97 |
-
st.image('fauvism.png', width=
|
| 98 |
|
| 99 |
with col2:
|
| 100 |
st.markdown('Aurora GAN [model](https://huggingface.co/huggan/fastgan-few-shot-aurora-bs8)', unsafe_allow_html=True)
|
| 101 |
-
st.image('aurora.png', width=
|
| 102 |
|
| 103 |
with col3:
|
| 104 |
st.markdown('Painting GAN [model](https://huggingface.co/huggan/fastgan-few-shot-painting-bs8)', unsafe_allow_html=True)
|
| 105 |
-
st.image('painting.png', width=
|
| 106 |
with col4:
|
| 107 |
st.markdown('Shell GAN [model](https://huggingface.co/huggan/fastgan-few-shot-shells)', unsafe_allow_html=True)
|
| 108 |
-
st.image('shell.png', width=
|
| 109 |
|
| 110 |
st.markdown('___')
|
| 111 |
if st.checkbox('Click if you want to create one of your own !'):
|
|
@@ -122,9 +122,7 @@ def main():
|
|
| 122 |
generate_button = st.button('Get Image!')
|
| 123 |
if generate_button:
|
| 124 |
st.markdown("""
|
| 125 |
-
<small><i>Predictions may take up to 1 minute under high load.</i></small>
|
| 126 |
-
</br>
|
| 127 |
-
<small><i>Please stand by.</i></small>
|
| 128 |
""",
|
| 129 |
unsafe_allow_html=True,)
|
| 130 |
|
|
@@ -132,13 +130,13 @@ def main():
|
|
| 132 |
generator = load_generator(model_name[img_type])
|
| 133 |
gan_images = generate_images(generator, number_imgs)
|
| 134 |
with col12:
|
| 135 |
-
st.image(gan_images[0], width=
|
| 136 |
if len(gan_images) > 1:
|
| 137 |
with col13:
|
| 138 |
if len(gan_images) <= 2:
|
| 139 |
-
st.image(gan_images[1], width=
|
| 140 |
else:
|
| 141 |
-
st.image(gan_images[1:], width=
|
| 142 |
|
| 143 |
|
| 144 |
|
|
|
|
| 26 |
def load_generator(model_name_or_path):
|
| 27 |
generator = Generator(in_channels=256, out_channels=3)
|
| 28 |
generator = generator.from_pretrained(model_name_or_path, in_channels=256, out_channels=3)
|
| 29 |
+
_ = generator.to(device)
|
| 30 |
_ = generator.eval()
|
| 31 |
|
| 32 |
return generator
|
|
|
|
| 94 |
col1, col2, col3, col4 = st.columns([3,3,3,3])
|
| 95 |
with col1:
|
| 96 |
st.markdown('Fauvism GAN [model](https://huggingface.co/huggan/fastgan-few-shot-fauvism-still-life)', unsafe_allow_html=True)
|
| 97 |
+
st.image('fauvism.png', width=220)
|
| 98 |
|
| 99 |
with col2:
|
| 100 |
st.markdown('Aurora GAN [model](https://huggingface.co/huggan/fastgan-few-shot-aurora-bs8)', unsafe_allow_html=True)
|
| 101 |
+
st.image('aurora.png', width=220)
|
| 102 |
|
| 103 |
with col3:
|
| 104 |
st.markdown('Painting GAN [model](https://huggingface.co/huggan/fastgan-few-shot-painting-bs8)', unsafe_allow_html=True)
|
| 105 |
+
st.image('painting.png', width=220)
|
| 106 |
with col4:
|
| 107 |
st.markdown('Shell GAN [model](https://huggingface.co/huggan/fastgan-few-shot-shells)', unsafe_allow_html=True)
|
| 108 |
+
st.image('shell.png', width=220)
|
| 109 |
|
| 110 |
st.markdown('___')
|
| 111 |
if st.checkbox('Click if you want to create one of your own !'):
|
|
|
|
| 122 |
generate_button = st.button('Get Image!')
|
| 123 |
if generate_button:
|
| 124 |
st.markdown("""
|
| 125 |
+
<small><i>Predictions may take up to 1 minute under high load. Please stand by.</i></small>
|
|
|
|
|
|
|
| 126 |
""",
|
| 127 |
unsafe_allow_html=True,)
|
| 128 |
|
|
|
|
| 130 |
generator = load_generator(model_name[img_type])
|
| 131 |
gan_images = generate_images(generator, number_imgs)
|
| 132 |
with col12:
|
| 133 |
+
st.image(gan_images[0], width=300)
|
| 134 |
if len(gan_images) > 1:
|
| 135 |
with col13:
|
| 136 |
if len(gan_images) <= 2:
|
| 137 |
+
st.image(gan_images[1], width=300)
|
| 138 |
else:
|
| 139 |
+
st.image(gan_images[1:], width=150)
|
| 140 |
|
| 141 |
|
| 142 |
|