how to upload photo to replicate API using Django?

51 Views Asked by At

I need to use i2vgen-xl model in Replicate website using Replicate API in Django and I need to pass an image (not URL) but it gives me this error:

- input: prompt is required
- input.image: Does not match format 'uri'

view.py

def X(request):
    form = ImageForm()
    if request.method == 'POST':
        form = ImageForm(request.POST,request.FILES)
        if form.is_valid():
            form.save()
            image_name = str(form.cleaned_data['Image'])
            os.environ["REPLICATE_API_TOKEN"] = "X"
            image_path = rf"'media\images\\{image_name}"
            output = replicate.run(
            "ali-vilab/i2vgen-xl:5821a338d00033abaaba89080a17eb8783d9a17ed710a6b4246a18e0900ccad4",
            input={
                   "image": image_path
                } )
            print(output)

            
        else:
           print("image is invalid") 
    return render(request,"img2vid.html",{'form':form})
0

There are 0 best solutions below