File size: 3,560 Bytes
7ea4283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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)