LovnishVerma commited on
Commit
1945a19
·
verified ·
1 Parent(s): d4a996d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -17,6 +17,18 @@ if not hf_token:
17
  # Initialize the Hugging Face API
18
  api = HfApi()
19
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # Database setup
21
  DATABASE = "students.db"
22
 
@@ -57,12 +69,11 @@ def save_image_to_hugging_face(image, roll_no):
57
 
58
  # Upload to Hugging Face
59
  try:
60
- repo_name = "LovnishVerma/face_and_emotion_detection" # Replace with your repo details
61
  api.upload_file(
62
  path_or_fileobj=local_path,
63
  path_in_repo=filename,
64
- repo_id=repo_name,
65
- repo_type="dataset",
66
  token=hf_token # Pass the token directly
67
  )
68
  st.success(f"Image uploaded to Hugging Face: {filename}")
 
17
  # Initialize the Hugging Face API
18
  api = HfApi()
19
 
20
+ # Repository Details
21
+ REPO_NAME = "face_and_emotion_detection" # Replace with your desired repo name
22
+ REPO_ID = "LovnishVerma/" + REPO_NAME # Update "LovnishVerma" with your Hugging Face username
23
+ REPO_TYPE = "space" # Set to 'space' for Streamlit projects
24
+
25
+ # Ensure repository exists
26
+ try:
27
+ api.create_repo(repo_id=REPO_ID, repo_type=REPO_TYPE, token=hf_token, exist_ok=True)
28
+ st.success(f"Repository '{REPO_NAME}' is ready on Hugging Face!")
29
+ except Exception as e:
30
+ st.error(f"Error creating repository: {e}")
31
+
32
  # Database setup
33
  DATABASE = "students.db"
34
 
 
69
 
70
  # Upload to Hugging Face
71
  try:
 
72
  api.upload_file(
73
  path_or_fileobj=local_path,
74
  path_in_repo=filename,
75
+ repo_id=REPO_ID,
76
+ repo_type=REPO_TYPE,
77
  token=hf_token # Pass the token directly
78
  )
79
  st.success(f"Image uploaded to Hugging Face: {filename}")