Spaces:
Sleeping
Sleeping
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) | |