Beginners Question: Downloading Directly to Google Colab

So this line of code downloads files to my google drive. Specifically, in this example it places a Stable Diffusion model into a specific folder in my google drive.

!cd /content/gdrive/MyDrive/sd/stable-diffusion-webui/models/Stable-diffusion; wget https://huggingface.co/stabilityai/sdxl-turbo/resolve/main/sd_xl_turbo_1.0.safetensors?download=true --content-disposition

But! This alternative creating variables using a user input doesn’t work, and I can’t figure out why…

Contents_Folder = "/content/gdrive/MyDrive/sd/stable-diffusion-webui/models/Stable-diffusion" #@param {type:"string"}
Model_URL = "https://huggingface.co/stabilityai/stable-video-diffusion-img2vid/resolve/main/svd.safetensors?download=true" #@param {type:"string"}

!cd Contents_Folder; wget Model_URL --content-disposition

The error I get is the following:

/bin/bash: line 1: cd: Contents_Folder: No such file or directory
--2023-12-10 12:29:18--  http://model_url/
Resolving model_url (model_url)... failed: Name or service not known.
wget: unable to resolve host address ‘model_url’

What am I doing wrong?

Note: Beginner’s question, new to colab and Python

Put a $ before the variable names: $Contents_Folder

https://colab.research.google.com/github/PlantsAndPython/PlantsAndPython/blob/master/M_7_SCRIPTING_WITH_BASH/0_Lessons/7.1_Scripting_with_bash.ipynb

Thanks for your reply! That didn’t work unfortunately… but very useful link.

It works, I tested it. Let’s see your new code.

Yes it does!! I was adding the $ when creating the variable, not when calling it. Thanks so much for your help, and for pointing me to the right documentation :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.