Spaces:
Build error
Build error
edit streamlit version
Browse files- requirements.txt +1 -1
- src/app.py +4 -34
requirements.txt
CHANGED
|
@@ -7,6 +7,6 @@ peft>=0.11.0
|
|
| 7 |
torch>=2.0.0
|
| 8 |
torchvision>=0.15.0
|
| 9 |
Pillow>=10.0.0
|
| 10 |
-
streamlit=
|
| 11 |
numpy>=1.24.0
|
| 12 |
scipy>=1.11.0
|
|
|
|
| 7 |
torch>=2.0.0
|
| 8 |
torchvision>=0.15.0
|
| 9 |
Pillow>=10.0.0
|
| 10 |
+
streamlit>=1.50
|
| 11 |
numpy>=1.24.0
|
| 12 |
scipy>=1.11.0
|
src/app.py
CHANGED
|
@@ -39,16 +39,6 @@ from model.generator import PepeGenerator
|
|
| 39 |
from model.config import ModelConfig
|
| 40 |
from utils.image_processor import ImageProcessor
|
| 41 |
|
| 42 |
-
def supports_use_container_width():
|
| 43 |
-
"""Check if the current Streamlit version supports use_container_width parameter."""
|
| 44 |
-
try:
|
| 45 |
-
import pkg_resources
|
| 46 |
-
streamlit_version = pkg_resources.get_distribution("streamlit").version
|
| 47 |
-
# use_container_width was introduced in Streamlit 1.16.0
|
| 48 |
-
return tuple(map(int, streamlit_version.split('.')[:2])) >= (1, 16)
|
| 49 |
-
except:
|
| 50 |
-
return False
|
| 51 |
-
|
| 52 |
# Page config
|
| 53 |
st.set_page_config(
|
| 54 |
page_title="🐸 Pepe Meme Generator",
|
|
@@ -296,14 +286,9 @@ def main():
|
|
| 296 |
placeholder = st.empty()
|
| 297 |
|
| 298 |
if st.session_state.generated_images:
|
| 299 |
-
# Use use_container_width only if supported by Streamlit version
|
| 300 |
-
image_kwargs = {}
|
| 301 |
-
if supports_use_container_width():
|
| 302 |
-
image_kwargs['use_container_width'] = True
|
| 303 |
-
|
| 304 |
placeholder.image(
|
| 305 |
st.session_state.generated_images[-1],
|
| 306 |
-
|
| 307 |
)
|
| 308 |
else:
|
| 309 |
placeholder.info("Your meme will appear here...")
|
|
@@ -362,12 +347,7 @@ def main():
|
|
| 362 |
|
| 363 |
# Show result
|
| 364 |
if num_vars == 1:
|
| 365 |
-
|
| 366 |
-
image_kwargs = {}
|
| 367 |
-
if supports_use_container_width():
|
| 368 |
-
image_kwargs['use_container_width'] = True
|
| 369 |
-
|
| 370 |
-
placeholder.image(image, **image_kwargs)
|
| 371 |
|
| 372 |
# Download
|
| 373 |
buf = io.BytesIO()
|
|
@@ -383,12 +363,7 @@ def main():
|
|
| 383 |
cols = st.columns(min(num_vars, 2))
|
| 384 |
for idx, img in enumerate(st.session_state.generated_images[-num_vars:]):
|
| 385 |
with cols[idx % 2]:
|
| 386 |
-
|
| 387 |
-
image_kwargs = {}
|
| 388 |
-
if supports_use_container_width():
|
| 389 |
-
image_kwargs['use_container_width'] = True
|
| 390 |
-
|
| 391 |
-
st.image(img, **image_kwargs)
|
| 392 |
|
| 393 |
except Exception as e:
|
| 394 |
st.error(f"Error: {str(e)}")
|
|
@@ -403,12 +378,7 @@ def main():
|
|
| 403 |
cols = st.columns(4)
|
| 404 |
for idx, img in enumerate(reversed(st.session_state.generated_images[-8:])):
|
| 405 |
with cols[idx % 4]:
|
| 406 |
-
|
| 407 |
-
image_kwargs = {}
|
| 408 |
-
if supports_use_container_width():
|
| 409 |
-
image_kwargs['use_container_width'] = True
|
| 410 |
-
|
| 411 |
-
st.image(img, **image_kwargs)
|
| 412 |
|
| 413 |
# Footer
|
| 414 |
st.divider()
|
|
|
|
| 39 |
from model.config import ModelConfig
|
| 40 |
from utils.image_processor import ImageProcessor
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Page config
|
| 43 |
st.set_page_config(
|
| 44 |
page_title="🐸 Pepe Meme Generator",
|
|
|
|
| 286 |
placeholder = st.empty()
|
| 287 |
|
| 288 |
if st.session_state.generated_images:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
placeholder.image(
|
| 290 |
st.session_state.generated_images[-1],
|
| 291 |
+
use_column_width=True
|
| 292 |
)
|
| 293 |
else:
|
| 294 |
placeholder.info("Your meme will appear here...")
|
|
|
|
| 347 |
|
| 348 |
# Show result
|
| 349 |
if num_vars == 1:
|
| 350 |
+
placeholder.image(image, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
# Download
|
| 353 |
buf = io.BytesIO()
|
|
|
|
| 363 |
cols = st.columns(min(num_vars, 2))
|
| 364 |
for idx, img in enumerate(st.session_state.generated_images[-num_vars:]):
|
| 365 |
with cols[idx % 2]:
|
| 366 |
+
st.image(img, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
|
| 368 |
except Exception as e:
|
| 369 |
st.error(f"Error: {str(e)}")
|
|
|
|
| 378 |
cols = st.columns(4)
|
| 379 |
for idx, img in enumerate(reversed(st.session_state.generated_images[-8:])):
|
| 380 |
with cols[idx % 4]:
|
| 381 |
+
st.image(img, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
|
| 383 |
# Footer
|
| 384 |
st.divider()
|