perfect10tips / app.py
Larry Poole
Fix indentation and add error handling for sample loader
6facc25
Raw History Blame Contribute Delete
1.52 kB
import gradio as gr
from sample_pack import build_sample_pack
def analyze_placeholder():
return (
"Analysis placeholder: once the model is trained, this will run detection, "
"buck-size proxy, clustering, heatmaps, and the best 2-hour window per camera."
)
def _load_samples_impl():
folder = build_sample_pack(n=150)
return (
f"✅ Loaded **{folder}** with 150 sample deer images + `metadata.csv`.\n\n"
"Next, click **Analyze My Photos (placeholder)** to simulate the pipeline."
)
def load_and_show_samples():
import traceback
try:
return _load_samples_impl()
except Exception as e:
tb = traceback.format_exc()
return (
"❌ Error while loading sample data:\n\n"
f"**{e}**\n\n"
"<details><summary>Traceback</summary>\n\n"
f"```{tb}```\n\n"
"</details>"
)
with gr.Blocks() as demo:
gr.Markdown("# Deer Scout — Personalized Buck Patterns from Your Cameras")
with gr.Row():
with gr.Column():
use_samples = gr.Button("Use sample data")
status = gr.Markdown()
run_btn = gr.Button("Analyze My Photos (placeholder)", variant="primary")
with gr.Column():
output_md = gr.Markdown("Results will appear here after analysis.")
use_samples.click(load_and_show_samples, inputs=[], outputs=[status])
run_btn.click(lambda: analyze_placeholder(), inputs=[], outputs=[output_md])
demo.launch()