sammoftah commited on
Commit
c2f6f22
·
verified ·
1 Parent(s): 2eff62b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -528,7 +528,7 @@ Get your token at: https://huggingface.co/settings/tokens"""
528
  if negative_prompt:
529
  status += " (with era-appropriate exclusions)"
530
  return image, status
531
-
532
  except Exception as e:
533
  error_msg = f"❌ Generation failed: {str(e)}"
534
  # Add helpful context for common errors
@@ -607,8 +607,8 @@ def process_coordinates(lat: float, lon: float, year: int, month: int, day: int,
607
  participants = event.get("actors") or event.get("participants") or []
608
  if participants and source == "wikidata":
609
  timeline_md += f"_Participants: {', '.join(participants[:4])}_\n\n"
610
- else:
611
- timeline_md += "_No specific events found in database or Wikidata. Scene generated from era-appropriate context._"
612
 
613
  return image, prompt, hint, status, timeline_md
614
 
@@ -646,7 +646,7 @@ def create_app():
646
  --accent: #ffad7a;
647
  --accent-hover: #e8935c;
648
  --accent-subtle: rgba(255, 173, 122, 0.1);
649
-
650
  /* Shadows */
651
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
652
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
@@ -660,7 +660,7 @@ def create_app():
660
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif !important;
661
  -webkit-font-smoothing: antialiased;
662
  }
663
-
664
  .gradio-container {
665
  max-width: 100% !important;
666
  background: var(--bg-light) !important;
@@ -977,7 +977,7 @@ def create_app():
977
  footer {
978
  display: none !important;
979
  }
980
-
981
  /* Responsive */
982
  @media (max-width: 768px) {
983
  .main-grid {
@@ -1005,7 +1005,7 @@ def create_app():
1005
  <p>Generate historically accurate scenes from geospatial coordinates and date/time inputs</p>
1006
  </div>
1007
  """)
1008
-
1009
  with gr.Row(elem_classes="main-grid"):
1010
 
1011
  # Left Sidebar: Inputs
@@ -1014,7 +1014,7 @@ def create_app():
1014
  prompt_override = gr.Textbox(
1015
  label="Describe the scene (optional)",
1016
  placeholder="Create an image at 31.7785° N, 35.2296° E, April 3, 33 CE, 15:00 hours",
1017
- lines=4,
1018
  )
1019
  gr.Markdown("_When filled, coordinate inputs are locked so the prompt takes precedence._")
1020
 
@@ -1063,7 +1063,7 @@ def create_app():
1063
  gr.Markdown("### 🖼️ Generated Image")
1064
  image_output = gr.Image(
1065
  label="",
1066
- show_label=False,
1067
  height=600,
1068
  type="pil"
1069
  )
@@ -1337,7 +1337,7 @@ def find_available_port(start_port=7860, max_attempts=10):
1337
 
1338
  if __name__ == "__main__":
1339
  app = create_app()
1340
- # For Hugging Face Spaces, Gradio handles port automatically
1341
  # For local development, allow port override via environment variable
1342
  port = os.getenv("GRADIO_SERVER_PORT")
1343
  if port:
@@ -1347,5 +1347,5 @@ if __name__ == "__main__":
1347
  except ValueError:
1348
  app.launch(server_name="0.0.0.0", share=False)
1349
  else:
1350
- # Hugging Face Spaces - let Gradio handle port automatically
1351
- app.launch(server_name="0.0.0.0", share=False)
 
528
  if negative_prompt:
529
  status += " (with era-appropriate exclusions)"
530
  return image, status
531
+
532
  except Exception as e:
533
  error_msg = f"❌ Generation failed: {str(e)}"
534
  # Add helpful context for common errors
 
607
  participants = event.get("actors") or event.get("participants") or []
608
  if participants and source == "wikidata":
609
  timeline_md += f"_Participants: {', '.join(participants[:4])}_\n\n"
610
+ else:
611
+ timeline_md += "_No specific events found in database or Wikidata. Scene generated from era-appropriate context._"
612
 
613
  return image, prompt, hint, status, timeline_md
614
 
 
646
  --accent: #ffad7a;
647
  --accent-hover: #e8935c;
648
  --accent-subtle: rgba(255, 173, 122, 0.1);
649
+
650
  /* Shadows */
651
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
652
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
 
660
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif !important;
661
  -webkit-font-smoothing: antialiased;
662
  }
663
+
664
  .gradio-container {
665
  max-width: 100% !important;
666
  background: var(--bg-light) !important;
 
977
  footer {
978
  display: none !important;
979
  }
980
+
981
  /* Responsive */
982
  @media (max-width: 768px) {
983
  .main-grid {
 
1005
  <p>Generate historically accurate scenes from geospatial coordinates and date/time inputs</p>
1006
  </div>
1007
  """)
1008
+
1009
  with gr.Row(elem_classes="main-grid"):
1010
 
1011
  # Left Sidebar: Inputs
 
1014
  prompt_override = gr.Textbox(
1015
  label="Describe the scene (optional)",
1016
  placeholder="Create an image at 31.7785° N, 35.2296° E, April 3, 33 CE, 15:00 hours",
1017
+ lines=4,
1018
  )
1019
  gr.Markdown("_When filled, coordinate inputs are locked so the prompt takes precedence._")
1020
 
 
1063
  gr.Markdown("### 🖼️ Generated Image")
1064
  image_output = gr.Image(
1065
  label="",
1066
+ show_label=False,
1067
  height=600,
1068
  type="pil"
1069
  )
 
1337
 
1338
  if __name__ == "__main__":
1339
  app = create_app()
1340
+ # Hugging Face Spaces handles port automatically
1341
  # For local development, allow port override via environment variable
1342
  port = os.getenv("GRADIO_SERVER_PORT")
1343
  if port:
 
1347
  except ValueError:
1348
  app.launch(server_name="0.0.0.0", share=False)
1349
  else:
1350
+ # Hugging Face Spaces - let Gradio handle everything automatically
1351
+ app.launch()