Oops, you created a Hugging Face token with read permissions only. You need one with write permissions

#23
by Pasha49 - opened

Local install. A proven token is inserted with Write role.

Traceback (most recent call last):
  File "/home/p/dreambooth-training/app.py", line 141, in validate_model_upload
    update_repo_visibility(repo_id=os.environ['SPACE_ID'], private=True, token=hf_token, repo_type="space")
  File "/usr/lib/python3.10/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'SPACE_ID'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/gradio/routes.py", line 292, in run_predict
    output = await app.blocks.process_api(
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/gradio/blocks.py", line 1007, in process_api
    result = await self.call_function(fn_index, inputs, iterator, request)
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/gradio/blocks.py", line 848, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/home/p/dreambooth-training/env/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/home/p/dreambooth-training/app.py", line 158, in train
    validate_model_upload(hf_token, model_name)
  File "/home/p/dreambooth-training/app.py", line 143, in validate_model_upload
    raise gr.Error("Oops, you created a Hugging Face token with read permissions only. You need one with write permissions")
gradio.exceptions.Error: 'Oops, you created a Hugging Face token with read permissions only. You need one with write permissions'

You need to create an environment variable called SPACE_ID. It's the name of the space where your Finetuned model will be uploaded in the end.

For running locally, you can set remove_attribution_after = False at the begin of def train(), it will skip for checking SPACE_ID

Thanks for flagging this. I made this check on my end too so one can run it locally without code changes!

multimodalart changed discussion status to closed

Sign up or log in to comment