Spaces:
Sleeping
Sleeping
File size: 1,190 Bytes
0722a5f b10052f abcae31 e97d346 116dd2d a1e0e22 116dd2d ac73b86 d19fe76 c525698 a09c804 c525698 |
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 |
import streamlit as st
from transformers import pipeline
print ("Loading model....")
#Title and Description
st.title("programming language identification")
st.write("""
### Powered bu Hugging Face and Streamlit
This app uses a pre-trained model from Hugging Face to identificate programming language.
Enter a programming language to determine what language it is!
""")
#Initialize Hugging Face Language identification pipeline
@st.cache_resource
def load_model():
print("before load model")
return pipeline("text-classification", model="huggingface/CodeBERTa-language-id")
language_identificator = load_model()
# Input Test from User
user_input = st.text_area("Enter some code to analyze",)
#Identificate language
if st.button("Identificate Language"):
print("button click")
if user_input.strip():
result = language_identificator(user_input)[0]
language = result['label']
score = result['score']
#Display the Result
st.subheader("Language Identification Result")
st.write(f"**Language:** {language}")
st.write(f"**Score:** {score:.2f}")
else:
st.warning("Please enter some code to analyze!") |