Spaces:
Running
Running
import streamlit as st | |
from transformers import pipeline | |
# Load the model from Hugging Face | |
model_name = "dejanseo/CTR-ZD" | |
model_pipeline = pipeline("text-classification", model=model_name) | |
# Mapping for the labels | |
labels_mapping = { | |
"LABEL_0": "Neutral impact", | |
"LABEL_1": "Positive impact", | |
"LABEL_2": "Negative impact" | |
} | |
def predict_title_impact(query, title): | |
# Concatenate query and title | |
input_text = f"{query} {title}" | |
predictions = model_pipeline(input_text) | |
return predictions | |
# Streamlit app | |
st.title("HTML Title CTR Prediction") | |
st.write("Predict the likelihood of a HTML title having an impact on CTR (click-through rate).") | |
# Input for the query and HTML title | |
query = st.text_input("Enter the Query:") | |
title = st.text_input("Enter the HTML Title:") | |
# Predict button | |
if st.button("Predict"): | |
if query and title: | |
predictions = predict_title_impact(query, title) | |
for prediction in predictions: | |
label = labels_mapping.get(prediction['label'], "Unknown") | |
st.write(f"Prediction: {label}") | |
st.write(f"Confidence: {prediction['score']:.2f}") | |
else: | |
st.write("Please enter both a query and an HTML title.") | |