Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training fail when passing file handle to create training for stability-ai's sdxl "Training failed. input_images_filetype must be zip or tar" #362

Open
abdul7235 opened this issue Oct 2, 2024 · 2 comments

Comments

@abdul7235
Copy link

I am opening the file handler and passing it to the replicate.trainings.create, my file

file_input = open(f"{file_name}","rb")

training = replicate.trainings.create(
model="stability-ai/sdxl",
version="7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc",
input={
"input_images": file_input,
"token_string": "TOK",
"caption_prefix": "a photo of TOK",
"max_train_steps": 1000,
"use_face_detection_instead": False
},
destination=f"{OWNER}/{training_data.model_name}"
)

I get following message in the logs:

**Training failed.

input_images_filetype must be zip or tar
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/cog/server/worker.py", line 349, in _predict
result = predict(payload)
File "train.py", line 142, in train
input_dir = preprocess(
File "/src/preprocess.py", line 118, in preprocess
assert False, "input_images_filetype must be zip or tar"
AssertionError: input_images_filetype must be zip or tar

However on the web interface I can see a valid zip file uploaded which if I download and open is valid (screenshot attached)
image

please help me sort it out.

@abdul7235
Copy link
Author

Solution

I was able to solve it after a day long effort.

Here is how I was able to send local zip file for training:

   filename = "images.zip"
   with open(f"{filename}", "rb") as file_input:
        encoded_data = base64.b64encode(file_input.read())


    encoded_data_str = encoded_data.decode('utf-8')

    


    training = replicate.trainings.create(
        model="stability-ai/sdxl",
        version="7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc",
        input={
            "input_images": f"data:application/zip;base64,{encoded_data_str}",
            "token_string": "TOK",
            "caption_prefix": "a photo of TOK",
            "max_train_steps": 1000,
            "use_face_detection_instead": False
        },
        destination=f"{OWNER}/{model_name}"
    )

@abdul7235
Copy link
Author

This needs to be added in the documentation please.

@abdul7235 abdul7235 reopened this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant