i just want to print the first label: loc1lay1
import streamlit as st
import requests
API_URL = “https://api-inference.huggingface.co/models/dendimaki/few-shots-apeiron-model-v2”
HEADERS = {“Authorization”: “Bearer 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”}
def query(payload):
try:
response = requests.post(API_URL, headers=HEADERS, json=payload)
response.raise_for_status() # Raise an error for non-200 responses
return response.json()
except requests.exceptions.RequestException as e:
st.error(f"An error occurred: {str(e)}")
return None
def main():
with open(‘style.css’) as f:
st.markdown(f’{f.read()}', unsafe_allow_html=True)
st.markdown("<h1 style='text-align: center; color: white;'>LOGIN</h1>", unsafe_allow_html=True)
name = st.text_input("Enter your name")
st.button('submit')
# Display the AI MARTIN MATRIX DATA CHECKER header
st.markdown("<h1 style='text-align: center; color: white;'>AI MARTIN MATRIX DATA CHECKER</h1>", unsafe_allow_html=True)
st.write("""This app will perform a classification of where you're at based on a Martin Matrix that can help us to collect the right data for our model.""")
# Get user input
ques = st.text_input("What are you feeling right now?")
if ques:
# Perform model inference using the provided API
output = query({"inputs": ques})
if output:
# Check if the output is a list and not empty
if isinstance(output, list) and output:
# Extract the label from the first dictionary in the list
predicted_label = output[0]
st.write(f"Predicted Label: {predicted_label}")
else:
st.write("Unexpected format in the model output.")
else:
st.write("No model output available at the moment. Please try again later.")
if name == “main”:
main()