SivaMallikarjun commited on
Commit
7ea4283
Β·
verified Β·
1 Parent(s): 5ade4bf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+
5
+ def classify_fish(image):
6
+ return {"Baby": 0.1, "Small": 0.2, "Medium": 0.5, "Large": 0.2}
7
+
8
+ def emit_sound(frequency: int):
9
+ return f"Emitting sound at {frequency} Hz"
10
+
11
+ def fish_classification_ui(image):
12
+ result = classify_fish(image)
13
+ return result
14
+
15
+ def sound_control_ui(frequency):
16
+ return emit_sound(frequency)
17
+
18
+ def chat_bot(message):
19
+ message = message.lower()
20
+ qa_pairs = {
21
+ "status": "🧠 AI Agent is running fine. Monitoring in progress.",
22
+ "fish": "πŸ“Š We detect Baby, Small, Medium, and Large fish. Currently focusing on high-value species.",
23
+ "sound": "πŸ”Š Emitting pulsed low-frequency sound to attract fish safely.",
24
+ "species": "🐟 High-demand species detected include Rohu, Katla, Murrel.",
25
+ "how many": "πŸ“ˆ Estimated fish count: Baby - 20, Small - 15, Medium - 10, Large - 5.",
26
+ "quality": "βœ… Fish health and activity levels look optimal.",
27
+ "ocr": "πŸ” OCR scanning dam gate status and water markings.",
28
+ "ner": "🧠 NER detects and classifies fish species from scientific names in camera labels.",
29
+ "camera": "πŸŽ₯ Camera feed processed via CNN for size and movement analysis.",
30
+ "size": "πŸ“ Fish size is auto-categorized as Baby, Small, Medium, or Large using our model.",
31
+ "dead fish": "⚠️ No dead fish detected near the thrust gates currently.",
32
+ "thrust gate": "πŸšͺ Monitoring open/close cycle and alerting when fish are near during thrust events.",
33
+ "maintenance": "πŸ› οΈ Regular AI system checks scheduled weekly.",
34
+ "data": "πŸ“Š Sensor data streamed every 2 seconds from riverbanks and gates.",
35
+ "alert": "🚨 Auto-alerts sent to fishermen if high movement or danger is detected.",
36
+ "chat": "πŸ’¬ I can assist engineers and fishermen with system status, fish count, and more.",
37
+ "retrain": "πŸ§‘β€πŸ’» Retraining is supported manually with new images via UI.",
38
+ "dashboard": "πŸ“Š The live dashboard shows fish count, sound activity, and gate logs.",
39
+ "developer": "πŸ‘¨β€πŸ’» Developed by EchoFishAI with Gradio, CNN, and RL techniques.",
40
+ "help": "πŸ“˜ You can ask about fish, gate status, sound, camera, or system alerts."
41
+ }
42
+
43
+ for key in qa_pairs:
44
+ if key in message:
45
+ return qa_pairs[key]
46
+ return "πŸ€– Hello! Ask me about fish, sound, species, status, gates, or AI system help."
47
+
48
+ with gr.Blocks() as demo:
49
+ gr.Markdown("# EchoFishAI 🐟")
50
+ gr.Markdown("Smart Fish Tracking & Attraction System with AI")
51
+
52
+ with gr.Tab("Fish Classifier"):
53
+ with gr.Row():
54
+ image_input = gr.Image(type="pil")
55
+ output = gr.Label()
56
+ classify_btn = gr.Button("Classify Fish")
57
+ classify_btn.click(fish_classification_ui, inputs=image_input, outputs=output)
58
+
59
+ with gr.Tab("Sound Emission"):
60
+ with gr.Row():
61
+ freq_input = gr.Slider(minimum=10, maximum=1000, step=10, label="Frequency (Hz)")
62
+ sound_output = gr.Textbox()
63
+ emit_btn = gr.Button("Emit Sound")
64
+ emit_btn.click(sound_control_ui, inputs=freq_input, outputs=sound_output)
65
+
66
+ with gr.Tab("Ask AI Agent"):
67
+ with gr.Row():
68
+ chatbot_input = gr.Textbox(label="Ask something...")
69
+ chatbot_output = gr.Textbox(label="Response")
70
+ chat_btn = gr.Button("Send")
71
+ chat_btn.click(chat_bot, inputs=chatbot_input, outputs=chatbot_output)
72
+
73
+ if __name__ == "__main__":
74
+ demo.launch(debug=True)