HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name':


I am trying to read the hf model directly from s3 on sagemaker studio. I am getting ‘HFValidationError’ error. I am putting my code below:

`from transformers import T5Tokenizer, T5ForConditionalGeneration

Specify the S3 URL to your model and tokenizer

model_url = “s3://bucketname/model/”

Load the model and tokenizer from S3

tokenizer = T5Tokenizer.from_pretrained(model_url)
model = T5ForConditionalGeneration.from_pretrained(model_url)

Now you can use the model and tokenizer for inference

input_text = “translate English to German: How old are you?”
input_ids = tokenizer(input_text, return_tensors=“pt”, truncation=True, padding=True, max_length=512)

outputs = model.generate(input_ids)

I am able to see the model by running below code on sagemaker, so i am sure the path is correct.

`s3 = boto3.client(‘s3’)

List all objects in the model folder from S3

s3_resource = boto3.resource(‘s3’)
my_bucket = s3_resource.Bucket(bucket_name)
for object_summary in my_bucket.objects.filter(Prefix=‘’):
file_path = object_summary.key
file_name = os.path.basename(file_path)
if file_name:

Can you please help me? Thanks :slight_smile:


I need help with this too!