File size: 1,131 Bytes
3cc27e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import qrcode

# Set the title of the Streamlit app
st.title("Hugging Face QR Code Generator")

# Allow the user to choose between generating a QR code for a model or a dataset
type_choice = st.radio("Select type:", ("Model", "Dataset"))

# Text input for the user to enter the model or dataset identifier
identifier = st.text_input("Enter the identifier:")

# Check if the user has entered an identifier
if identifier:
    # Construct the URL based on the selected type
    if type_choice == "Model":
        url = f"https://huggingface.co/{identifier}"
    else:  # Dataset
        url = f"https://huggingface.co/datasets/{identifier}"
    
    # Generate the QR code from the URL
    img = qrcode.make(url)
    
    # Display the QR code in the app with a caption
    st.image(img, caption=f"Scan this QR code to visit the {type_choice.lower()} page")
    
    # Show the URL that the QR code links to for verification
    st.write(f"This QR code links to: {url}")
else:
    # Prompt the user to enter an identifier if the input is empty
    st.write("Please enter an identifier to generate the QR code.")