Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,9 +18,16 @@ import random
|
|
| 18 |
import logging
|
| 19 |
import numpy as np
|
| 20 |
|
| 21 |
-
# Logging setup
|
| 22 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
| 23 |
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Page Configuration
|
| 26 |
st.set_page_config(
|
|
@@ -200,6 +207,13 @@ class DiffusionBuilder:
|
|
| 200 |
return self.pipeline(prompt, num_inference_steps=50).images[0]
|
| 201 |
|
| 202 |
# Utility Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
def get_download_link(file_path, mime_type="text/plain", label="Download"):
|
| 204 |
with open(file_path, 'rb') as f:
|
| 205 |
data = f.read()
|
|
@@ -466,9 +480,9 @@ with tab5:
|
|
| 466 |
image = agent.generate(row["Image Idea"])
|
| 467 |
st.image(image, caption=f"{row['Theme']} - {row['Image Idea']}")
|
| 468 |
|
| 469 |
-
#
|
| 470 |
st.sidebar.subheader("Action Logs 📜")
|
| 471 |
log_container = st.sidebar.empty()
|
| 472 |
with log_container:
|
| 473 |
-
for record in
|
| 474 |
st.write(f"{record.asctime} - {record.levelname} - {record.message}")
|
|
|
|
| 18 |
import logging
|
| 19 |
import numpy as np
|
| 20 |
|
| 21 |
+
# Logging setup with a custom buffer
|
| 22 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
| 23 |
logger = logging.getLogger(__name__)
|
| 24 |
+
log_records = [] # Custom list to store log records
|
| 25 |
+
|
| 26 |
+
class LogCaptureHandler(logging.Handler):
|
| 27 |
+
def emit(self, record):
|
| 28 |
+
log_records.append(record)
|
| 29 |
+
|
| 30 |
+
logger.addHandler(LogCaptureHandler())
|
| 31 |
|
| 32 |
# Page Configuration
|
| 33 |
st.set_page_config(
|
|
|
|
| 207 |
return self.pipeline(prompt, num_inference_steps=50).images[0]
|
| 208 |
|
| 209 |
# Utility Functions
|
| 210 |
+
def generate_filename(sequence, ext="png"):
|
| 211 |
+
from datetime import datetime
|
| 212 |
+
import pytz
|
| 213 |
+
central = pytz.timezone('US/Central')
|
| 214 |
+
timestamp = datetime.now(central).strftime("%d%m%Y%H%M%S%p")
|
| 215 |
+
return f"{sequence}{timestamp}.{ext}"
|
| 216 |
+
|
| 217 |
def get_download_link(file_path, mime_type="text/plain", label="Download"):
|
| 218 |
with open(file_path, 'rb') as f:
|
| 219 |
data = f.read()
|
|
|
|
| 480 |
image = agent.generate(row["Image Idea"])
|
| 481 |
st.image(image, caption=f"{row['Theme']} - {row['Image Idea']}")
|
| 482 |
|
| 483 |
+
# Display Logs
|
| 484 |
st.sidebar.subheader("Action Logs 📜")
|
| 485 |
log_container = st.sidebar.empty()
|
| 486 |
with log_container:
|
| 487 |
+
for record in log_records:
|
| 488 |
st.write(f"{record.asctime} - {record.levelname} - {record.message}")
|