reach-vb HF staff commited on
Commit
5808c09
·
verified ·
1 Parent(s): 5f2441e

Update app.py (#11)

Browse files

- Update app.py (931f37e9ab5b1e2744612609c6c22aabfde7f7ba)

Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -30,7 +30,8 @@ def fetch_manifest(image, tag):
30
  else:
31
  return None
32
 
33
- def upload_to_huggingface(repo_id, folder_path, token):
 
34
  api = HfApi(token=token)
35
  repo_path = api.create_repo(repo_id=repo_id, repo_type="model", exist_ok=True)
36
  print(f"Repo created {repo_path}")
@@ -47,8 +48,6 @@ def upload_to_huggingface(repo_id, folder_path, token):
47
  def process_image_tag(image_tag, repo_id, oauth_token: Union[gr.OAuthToken, None]):
48
  # Extract image and tag from the input
49
  try:
50
- token = oauth_token.token if oauth_token else None
51
-
52
  image, tag = image_tag.split(':')
53
 
54
  # Fetch the manifest JSON
@@ -75,7 +74,7 @@ def process_image_tag(image_tag, repo_id, oauth_token: Union[gr.OAuthToken, None
75
  download_file(config_digest, image)
76
 
77
  # Upload to Hugging Face Hub
78
- upload_result = upload_to_huggingface(repo_id, 'blobs/*', token=token)
79
 
80
  # Delete the blobs folder
81
  shutil.rmtree('blobs')
 
30
  else:
31
  return None
32
 
33
+ def upload_to_huggingface(repo_id, folder_path, oauth_token: Union[gr.OAuthToken, None])):
34
+ token = oauth_token.token if oauth_token else None
35
  api = HfApi(token=token)
36
  repo_path = api.create_repo(repo_id=repo_id, repo_type="model", exist_ok=True)
37
  print(f"Repo created {repo_path}")
 
48
  def process_image_tag(image_tag, repo_id, oauth_token: Union[gr.OAuthToken, None]):
49
  # Extract image and tag from the input
50
  try:
 
 
51
  image, tag = image_tag.split(':')
52
 
53
  # Fetch the manifest JSON
 
74
  download_file(config_digest, image)
75
 
76
  # Upload to Hugging Face Hub
77
+ upload_result = upload_to_huggingface(repo_id, 'blobs/*', oauth_token)
78
 
79
  # Delete the blobs folder
80
  shutil.rmtree('blobs')