Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
x = st.slider('Select a value')
|
4 |
+
st.write(x, 'squared is', x * x)
|
5 |
+
|
6 |
+
from transformers import HfApi
|
7 |
+
|
8 |
+
def upload_file_to_huggingface(file_url, filename, api_token):
|
9 |
+
# Download the file from the URL
|
10 |
+
response = requests.get(file_url)
|
11 |
+
file_content = response.content
|
12 |
+
|
13 |
+
# Initialize the Hugging Face API client
|
14 |
+
hf_api = HfApi()
|
15 |
+
hf_api.set_access_token(api_token)
|
16 |
+
|
17 |
+
# Upload the file to Hugging Face
|
18 |
+
hf_api.upload_file(filename, file_content)
|
19 |
+
|
20 |
+
print(f"File uploaded to Hugging Face as {filename}")
|
21 |
+
|
22 |
+
# Replace 'your-api-token' with your actual Hugging Face API token
|
23 |
+
api_token = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
|
24 |
+
file_url = 'https://dkstatics-public.digikala.com/digikala-products/26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
|
25 |
+
filename = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
|
26 |
+
|
27 |
+
upload_file_to_huggingface(file_url, filename, api_token)
|