Spaces:
Running
Running
import streamlit as st | |
import requests | |
from bs4 import BeautifulSoup | |
from transformers import pipeline | |
# Set up MBTI classifier | |
classifier = pipeline("text-classification", model="pandalla/MBTIGPT_en_ENTP") | |
def scrape_mbti_lounge(mbti_type): | |
url = f"https://mbtilounge.com/mbti/{mbti_type}" | |
response = requests.get(url) | |
soup = BeautifulSoup(response.text, 'html.parser') | |
# Extract relevant information (adjust selectors as needed) | |
description = soup.find('div', class_='type-description').text | |
return description | |
st.title("MBTI Lookup and Classification") | |
user_input = st.text_area("Enter text to classify MBTI type:") | |
if user_input: | |
# Classify MBTI type | |
result = classifier(user_input)[0] | |
predicted_type = result['label'] | |
confidence = result['score'] | |
st.write(f"Predicted MBTI Type: {predicted_type}") | |
st.write(f"Confidence: {confidence:.2f}") | |
# Fetch MBTI type description from MBTI Lounge | |
description = scrape_mbti_lounge(predicted_type) | |
st.subheader(f"Description for {predicted_type}:") | |
st.write(description) | |