Spaces:
Runtime error
Runtime error
File size: 1,152 Bytes
f93f483 57d4935 f370b67 f93f483 57d4935 f370b67 f93f483 57d4935 f370b67 f93f483 57d4935 f370b67 57d4935 f370b67 57d4935 f93f483 f370b67 57d4935 f370b67 f93f483 57d4935 f370b67 f93f483 57d4935 f370b67 |
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 |
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
from datasets import load_dataset
import gradio as gr
# Load the classifier pipeline for sentiment analysis (if needed)
classifier = pipeline("sentiment-analysis")
# Load model and tokenizer
model_name = "ckcl/mexc_price_model"
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Use AutoModelForSequenceClassification or the appropriate model class
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Load dataset
ds = load_dataset("ckcl/BTC_USDT_dataset")
# Define the prediction function
def predict(input_text):
# Tokenize input
inputs = tokenizer(input_text, return_tensors="pt")
# Make predictions
with torch.no_grad():
outputs = model(**inputs)
# Extract prediction results
predictions = torch.argmax(outputs.logits, dim=-1)
return str(predictions.item())
# Create Gradio interface
iface = gr.Interface(fn=predict, inputs="text", outputs="text", title="MEXC Contract Prediction", description="Predict contract prices for MEXC.")
# Launch the application
iface.launch()
|