awacke1 commited on
Commit
48a7ffa
·
verified ·
1 Parent(s): c1c0ef5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -155
app.py CHANGED
@@ -7,6 +7,11 @@ import json
7
  import os
8
  import pandas as pd
9
  import pytz
 
 
 
 
 
10
  import random
11
  import re
12
  import shutil
@@ -876,38 +881,38 @@ def add_video_generation_ui(container):
876
  """Enhanced video generation UI with improved file handling"""
877
  st.markdown("### 🎥 Video Generation")
878
 
879
- #col1, col2 = st.columns([2, 1])
880
- #with col1:
881
-
882
- uploaded_file = st.file_uploader(
883
  "Upload Image for Video Generation 🖼️",
884
  type=['png', 'jpg', 'jpeg'],
885
  help="Upload a clear, well-lit image. Recommended size: 576x1024 pixels."
886
  )
887
 
888
- #with col2:
889
- st.markdown("#### Generation Parameters")
890
- motion_bucket_id = st.slider(
891
- "Motion Intensity 🌊",
892
- min_value=1,
893
- max_value=255,
894
- value=127,
895
- help="Lower values create subtle movement, higher values create more dramatic motion"
896
- )
897
- fps_id = st.slider(
898
- "Frames per Second 🎬",
899
- min_value=1,
900
- max_value=30,
901
- value=6,
902
- help="Higher values create smoother but potentially less stable videos"
903
- )
904
-
905
- with st.expander("Advanced Options"):
906
- use_custom_seed = st.checkbox("Use Custom Seed")
907
- if use_custom_seed:
908
- seed = st.number_input("Seed Value", value=int(time.time() * 1000))
909
- else:
910
- seed = None
911
 
912
  if uploaded_file is not None:
913
  try:
@@ -1133,8 +1138,6 @@ def main():
1133
  # 📝 Document handling - "Document, document, on the wall, who's the most recent of them all?"
1134
  documents = get_documents(container)
1135
  total_docs = len(documents)
1136
-
1137
-
1138
  # Add a slider to let the user choose how many documents to display
1139
  num_docs_to_display = st.slider(
1140
  "Select number of documents to display", 1, 20, 1
@@ -1149,7 +1152,7 @@ def main():
1149
 
1150
  if documents_to_display:
1151
  # 🎨 View options - "Different strokes for different folks"
1152
- view_options = ['Show as Markdown', 'Show as Code Editor', 'Show as Run AI', 'Show as Run Media AI', 'Clone Document', 'New Record']
1153
  selected_view = st.sidebar.selectbox("Select Viewer/Editor", view_options, index=2)
1154
 
1155
 
@@ -1292,131 +1295,6 @@ def main():
1292
  num_cols = len(documents_to_display)
1293
  cols = st.columns(num_cols)
1294
 
1295
- for idx, (col, doc) in enumerate(zip(cols, documents_to_display)):
1296
- with col:
1297
- # ID and Name fields
1298
- editable_id = st.text_input("ID", value=doc.get('id', ''), key=f'edit_id_{idx}')
1299
- editable_name = st.text_input("Name", value=doc.get('name', ''), key=f'edit_name_{idx}')
1300
-
1301
- # Create editable document copy without id and name
1302
- editable_doc = doc.copy()
1303
- editable_doc.pop('id', None)
1304
- editable_doc.pop('name', None)
1305
-
1306
- doc_str = st.text_area("Document Content (in JSON format)",
1307
- value=json.dumps(editable_doc, indent=2),
1308
- height=300,
1309
- key=f'doc_str_{idx}')
1310
-
1311
- if st.button("🤖 Run AI", key=f'run_with_ai_button_{idx}'):
1312
- # Your existing AI processing code here
1313
- values_with_space = []
1314
- def extract_values2(obj):
1315
- if isinstance(obj, dict):
1316
- for k, v in obj.items():
1317
- extract_values2(v)
1318
- elif isinstance(obj, list):
1319
- for item in obj:
1320
- extract_values2(item)
1321
- elif isinstance(obj, str):
1322
- if ' ' in obj:
1323
- values_with_space.append(obj)
1324
-
1325
- extract_values2(doc)
1326
- for term in values_with_space:
1327
- display_glossary_entity(term)
1328
- search_glossary(term)
1329
-
1330
- if st.button("💾 Save Changes", key=f'save_runai_{idx}'):
1331
- try:
1332
- updated_doc = json.loads(doc_str)
1333
- # Reinsert ID and name from editable fields
1334
- updated_doc['id'] = editable_id
1335
- updated_doc['name'] = editable_name
1336
- response = container.upsert_item(body=updated_doc)
1337
- if response:
1338
- st.success(f"Document {updated_doc['id']} saved successfully.")
1339
- st.session_state.selected_document_id = updated_doc['id']
1340
- st.rerun()
1341
- except Exception as e:
1342
- st.error(f"Error saving document: {str(e)}")
1343
-
1344
-
1345
- # File Editor (When you need to tweak things ✏️)
1346
- if hasattr(st.session_state, 'current_file'):
1347
- st.subheader(f"Editing: {st.session_state.current_file} 🛠")
1348
- new_content = st.text_area("File Content ✏️:", st.session_state.file_content, height=300)
1349
- if st.button("Save Changes 💾"):
1350
- with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
1351
- file.write(new_content)
1352
- st.success("File updated successfully! 🎉")
1353
-
1354
-
1355
-
1356
-
1357
-
1358
- # Image Gallery (For your viewing pleasure 📸)
1359
- st.subheader("Image Gallery 🖼")
1360
- image_files = glob.glob("*.png") + glob.glob("*.jpg") + glob.glob("*.jpeg")
1361
- image_cols = st.slider("Gallery Columns 🖼", min_value=1, max_value=20, value=10)
1362
- cols = st.columns(image_cols)
1363
- for idx, image_file in enumerate(image_files):
1364
- with cols[idx % image_cols]:
1365
- img = Image.open(image_file)
1366
- #st.image(img, caption=image_file, use_column_width=True)
1367
- st.image(img, use_column_width=True)
1368
- display_glossary_entity(os.path.splitext(image_file)[0])
1369
-
1370
-
1371
-
1372
-
1373
-
1374
-
1375
-
1376
- # Video Gallery (Let’s roll the tapes 🎬)
1377
- st.subheader("Video Gallery 🎥")
1378
- video_files = glob.glob("*.mp4")
1379
- video_cols = st.slider("Gallery Columns 🎬", min_value=1, max_value=10, value=5)
1380
- cols = st.columns(video_cols)
1381
- for idx, video_file in enumerate(video_files):
1382
- with cols[idx % video_cols]:
1383
- st.markdown(get_video_html(video_file, width="100%"), unsafe_allow_html=True)
1384
- display_glossary_entity(os.path.splitext(video_file)[0])
1385
-
1386
-
1387
-
1388
-
1389
-
1390
-
1391
-
1392
- # Audio Gallery (Tunes for the mood 🎶)
1393
- st.subheader("Audio Gallery 🎧")
1394
- audio_files = glob.glob("*.mp3") + glob.glob("*.wav")
1395
- audio_cols = st.slider("Gallery Columns 🎶", min_value=1, max_value=10, value=5)
1396
- cols = st.columns(audio_cols)
1397
- for idx, audio_file in enumerate(audio_files):
1398
- with cols[idx % audio_cols]:
1399
- st.markdown(get_audio_html(audio_file, width="100%"), unsafe_allow_html=True)
1400
- display_glossary_entity(os.path.splitext(audio_file)[0])
1401
-
1402
-
1403
-
1404
-
1405
-
1406
-
1407
-
1408
-
1409
- elif selected_view == 'Show as Run Media AI':
1410
- Label = '#### ✏️ Run AI with wisdom, save with precision'
1411
- st.markdown(Label)
1412
- num_cols = len(documents_to_display)
1413
- cols = st.columns(num_cols)
1414
-
1415
- # Video Generator call - the video generation UI for container:
1416
- add_video_generation_ui(container)
1417
-
1418
-
1419
-
1420
  for idx, (col, doc) in enumerate(zip(cols, documents_to_display)):
1421
  with col:
1422
  # ID and Name fields
@@ -1436,6 +1314,8 @@ def main():
1436
  # Save and AI operations columns
1437
 
1438
 
 
 
1439
 
1440
 
1441
 
 
7
  import os
8
  import pandas as pd
9
  import pytz
10
+
11
+
12
+
13
+
14
+
15
  import random
16
  import re
17
  import shutil
 
881
  """Enhanced video generation UI with improved file handling"""
882
  st.markdown("### 🎥 Video Generation")
883
 
884
+ col1, col2 = st.columns([2, 1])
885
+
886
+ with col1:
887
+ uploaded_file = st.file_uploader(
888
  "Upload Image for Video Generation 🖼️",
889
  type=['png', 'jpg', 'jpeg'],
890
  help="Upload a clear, well-lit image. Recommended size: 576x1024 pixels."
891
  )
892
 
893
+ with col2:
894
+ st.markdown("#### Generation Parameters")
895
+ motion_bucket_id = st.slider(
896
+ "Motion Intensity 🌊",
897
+ min_value=1,
898
+ max_value=255,
899
+ value=127,
900
+ help="Lower values create subtle movement, higher values create more dramatic motion"
901
+ )
902
+ fps_id = st.slider(
903
+ "Frames per Second 🎬",
904
+ min_value=1,
905
+ max_value=30,
906
+ value=6,
907
+ help="Higher values create smoother but potentially less stable videos"
908
+ )
909
+
910
+ with st.expander("Advanced Options"):
911
+ use_custom_seed = st.checkbox("Use Custom Seed")
912
+ if use_custom_seed:
913
+ seed = st.number_input("Seed Value", value=int(time.time() * 1000))
914
+ else:
915
+ seed = None
916
 
917
  if uploaded_file is not None:
918
  try:
 
1138
  # 📝 Document handling - "Document, document, on the wall, who's the most recent of them all?"
1139
  documents = get_documents(container)
1140
  total_docs = len(documents)
 
 
1141
  # Add a slider to let the user choose how many documents to display
1142
  num_docs_to_display = st.slider(
1143
  "Select number of documents to display", 1, 20, 1
 
1152
 
1153
  if documents_to_display:
1154
  # 🎨 View options - "Different strokes for different folks"
1155
+ view_options = ['Show as Markdown', 'Show as Code Editor', 'Show as Run AI', 'Clone Document', 'New Record']
1156
  selected_view = st.sidebar.selectbox("Select Viewer/Editor", view_options, index=2)
1157
 
1158
 
 
1295
  num_cols = len(documents_to_display)
1296
  cols = st.columns(num_cols)
1297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1298
  for idx, (col, doc) in enumerate(zip(cols, documents_to_display)):
1299
  with col:
1300
  # ID and Name fields
 
1314
  # Save and AI operations columns
1315
 
1316
 
1317
+ # Video Generator call - the video generation UI for container:
1318
+ add_video_generation_ui(container)
1319
 
1320
 
1321