Spaces:
Runtime error
Runtime error
Update app.py
Browse files11 unmodified lines1213141516171814 unmodified lines333435363738392 unmodified lines42434445464711 unmodified lines# Fixed promptFIXED_PROMPT = "Generate a funny caption from image"# Function to generate caption for the uploaded image with the fixed prompt# Function to generate caption for the uploaded image with the fixed promptdef generate_caption(image):# Preprocess the image14 unmodified linesbatch_size = image_tensor.shape[0]repeated_prompt_tensor = fixed_prompt_tensor.repeat(batch_size, 1)# Concatenate the prompt tensor with the image tensor along the sequence dimensioninput_tensor = torch.cat((repeated_prompt_tensor, image_tensor), dim=1)# Generate caption2 unmodified linesreturn caption# Streamlit appst.title("Cartoon Caption Generator")11 unmodified lines12131415161714 unmodified lines32333435363738394041422 unmodified lines4546474849505111 unmodified lines# Fixed promptFIXED_PROMPT = "Generate a funny caption from image"# Function to generate caption for the uploaded image with the fixed promptdef generate_caption(image):# Preprocess the image14 unmodified linesbatch_size = image_tensor.shape[0]repeated_prompt_tensor = fixed_prompt_tensor.repeat(batch_size, 1)# Reshape the image tensor to match the shape of the prompt tensor# The reshaping depends on the model's input requirementsimage_tensor = image_tensor.view(batch_size, -1)# Concatenate the prompt tensor with the reshaped image tensor along the sequence dimensioninput_tensor = torch.cat((repeated_prompt_tensor, image_tensor), dim=1)# Generate caption2 unmodified linesreturn caption# Streamlit appst.title("Cartoon Caption Generator")
app.py+6-2