File size: 938 Bytes
66c560c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

x = st.slider('Select a value')
st.write(x, 'squared is', x * x)

from transformers import HfApi

def upload_file_to_huggingface(file_url, filename, api_token):
    # Download the file from the URL
    response = requests.get(file_url)
    file_content = response.content

    # Initialize the Hugging Face API client
    hf_api = HfApi()
    hf_api.set_access_token(api_token)

    # Upload the file to Hugging Face
    hf_api.upload_file(filename, file_content)

    print(f"File uploaded to Hugging Face as {filename}")

# Replace 'your-api-token' with your actual Hugging Face API token
api_token = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
file_url = 'https://dkstatics-public.digikala.com/digikala-products/26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
filename = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'

upload_file_to_huggingface(file_url, filename, api_token)