File size: 1,313 Bytes
3e7fb54
 
56e7b68
3e7fb54
 
 
 
56e7b68
 
3e7fb54
0e79c88
3e7fb54
0e79c88
56e7b68
 
0e79c88
 
 
 
 
 
3e7fb54
 
 
 
0e79c88
 
3e7fb54
0e79c88
 
3e7fb54
 
 
 
 
 
 
 
 
047d22b
3e7fb54
 
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
import warnings
import gradio as gr
from proxy_model import RemoteModelProxy

# Suppress the FutureWarning
warnings.filterwarnings("ignore", category=FutureWarning, module="torch")

# Load the model via the proxy
model_proxy = RemoteModelProxy("deepseek-ai/DeepSeek-V3")

# Define the text classification function
def classify_text(text):
    try:
        result = model_proxy.classify_text(text)
        return result
    except Exception as e:
        print(f"Error during text classification: {e}")
        return {
            "Predicted Class": "Error",
            "Probabilities": []
        }

# Create a Gradio interface
try:
    iface = gr.Interface(
        fn=classify_text,  # Function to call
        inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),  # Input component
        outputs=[
            gr.Label(label="Predicted Class"),  # Output component for predicted class
            gr.Label(label="Probabilities")  # Output component for probabilities
        ],
        title="DeepSeek-V3 Text Classification",
        description="Classify text using the DeepSeek-V3 model."
    )
except Exception as e:
    print(f"Failed to create Gradio interface: {e}")

# Launch the interface
try:
    iface.launch()
except Exception as e:
    print(f"Failed to launch Gradio interface: {e}")