import gradio as gr import numpy as np from PIL import Image def classify_fish(image): return {"Baby": 0.1, "Small": 0.2, "Medium": 0.5, "Large": 0.2} def emit_sound(frequency: int): return f"Emitting sound at {frequency} Hz" def fish_classification_ui(image): result = classify_fish(image) return result def sound_control_ui(frequency): return emit_sound(frequency) def chat_bot(message): message = message.lower() qa_pairs = { "status": "🧠 AI Agent is running fine. Monitoring in progress.", "fish": "📊 We detect Baby, Small, Medium, and Large fish. Currently focusing on high-value species.", "sound": "🔊 Emitting pulsed low-frequency sound to attract fish safely.", "species": "🐟 High-demand species detected include Rohu, Katla, Murrel.", "how many": "📈 Estimated fish count: Baby - 20, Small - 15, Medium - 10, Large - 5.", "quality": "✅ Fish health and activity levels look optimal.", "ocr": "🔍 OCR scanning dam gate status and water markings.", "ner": "🧠 NER detects and classifies fish species from scientific names in camera labels.", "camera": "🎥 Camera feed processed via CNN for size and movement analysis.", "size": "📐 Fish size is auto-categorized as Baby, Small, Medium, or Large using our model.", "dead fish": "⚠️ No dead fish detected near the thrust gates currently.", "thrust gate": "🚪 Monitoring open/close cycle and alerting when fish are near during thrust events.", "maintenance": "🛠️ Regular AI system checks scheduled weekly.", "data": "📊 Sensor data streamed every 2 seconds from riverbanks and gates.", "alert": "🚨 Auto-alerts sent to fishermen if high movement or danger is detected.", "chat": "💬 I can assist engineers and fishermen with system status, fish count, and more.", "retrain": "🧑‍💻 Retraining is supported manually with new images via UI.", "dashboard": "📊 The live dashboard shows fish count, sound activity, and gate logs.", "developer": "👨‍💻 Developed by EchoFishAI with Gradio, CNN, and RL techniques.", "help": "📘 You can ask about fish, gate status, sound, camera, or system alerts." } for key in qa_pairs: if key in message: return qa_pairs[key] return "🤖 Hello! Ask me about fish, sound, species, status, gates, or AI system help." with gr.Blocks() as demo: gr.Markdown("# EchoFishAI 🐟") gr.Markdown("Smart Fish Tracking & Attraction System with AI") with gr.Tab("Fish Classifier"): with gr.Row(): image_input = gr.Image(type="pil") output = gr.Label() classify_btn = gr.Button("Classify Fish") classify_btn.click(fish_classification_ui, inputs=image_input, outputs=output) with gr.Tab("Sound Emission"): with gr.Row(): freq_input = gr.Slider(minimum=10, maximum=1000, step=10, label="Frequency (Hz)") sound_output = gr.Textbox() emit_btn = gr.Button("Emit Sound") emit_btn.click(sound_control_ui, inputs=freq_input, outputs=sound_output) with gr.Tab("Ask AI Agent"): with gr.Row(): chatbot_input = gr.Textbox(label="Ask something...") chatbot_output = gr.Textbox(label="Response") chat_btn = gr.Button("Send") chat_btn.click(chat_bot, inputs=chatbot_input, outputs=chatbot_output) if __name__ == "__main__": demo.launch(debug=True)