Spaces:
Runtime error
Runtime error
Delete inference.py
Browse files- inference.py +0 -39
inference.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import gradio as gr
|
| 3 |
-
|
| 4 |
-
# Environment variables – NO default for HF_TOKEN (must be None if missing)
|
| 5 |
-
API_BASE_URL = os.getenv("API_BASE_URL") # can have a default if you want, but the instruction says "defaults are set only for API_BASE_URL and MODEL_NAME"
|
| 6 |
-
MODEL_NAME = os.getenv("MODEL_NAME")
|
| 7 |
-
HF_TOKEN = os.getenv("HF_TOKEN") # MUST NOT have a default (no `or "something"`)
|
| 8 |
-
|
| 9 |
-
# Optional – only if you use from_docker_image()
|
| 10 |
-
LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME")
|
| 11 |
-
|
| 12 |
-
# Optional: If you need to use OpenAI client, configure it like:
|
| 13 |
-
# from openai import OpenAI
|
| 14 |
-
# client = OpenAI(api_key=HF_TOKEN, base_url=API_BASE_URL)
|
| 15 |
-
|
| 16 |
-
def predict(packet_data: str):
|
| 17 |
-
"""
|
| 18 |
-
Replace this with your actual MayOne detection logic.
|
| 19 |
-
You can import your existing framework modules if you copy them into the Space.
|
| 20 |
-
"""
|
| 21 |
-
# Dummy result – replace with real inference
|
| 22 |
-
result = {
|
| 23 |
-
"anomaly_score": 0.92,
|
| 24 |
-
"verdict": "malicious",
|
| 25 |
-
"model": MODEL_NAME or "MayOne-Security-Framework"
|
| 26 |
-
}
|
| 27 |
-
return result
|
| 28 |
-
|
| 29 |
-
# Create Gradio interface
|
| 30 |
-
demo = gr.Interface(
|
| 31 |
-
fn=predict,
|
| 32 |
-
inputs=gr.Textbox(label="Packet Data (hex or raw)", lines=5),
|
| 33 |
-
outputs=gr.JSON(label="Detection Result"),
|
| 34 |
-
title="MayOne Security Framework",
|
| 35 |
-
description="AI-powered network intrusion detection for Windows"
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
if __name__ == "__main__":
|
| 39 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|