Upgrading hf-hub to 0.2.0 (Modified API to not pass the Repo around

all the time)
This commit is contained in:
Nicolas Patry
2023-07-27 20:05:02 +02:00
parent f291065f6c
commit ca479a873e
5 changed files with 23 additions and 23 deletions

View File

@ -282,28 +282,23 @@ fn main() -> Result<()> {
std::path::PathBuf::from(args.input.expect("You didn't specify a file to read from yet, are using a local model, please add `--input example.wav` to read some audio file")),
)
} else {
let repo = Repo::with_revision(model_id, RepoType::Model, revision);
let api = Api::new()?;
let dataset = api.dataset("Narsil/candle-examples".to_string());
let repo = api.repo(Repo::with_revision(model_id, RepoType::Model, revision));
let sample = if let Some(input) = args.input {
if let Some(sample) = input.strip_prefix("sample:") {
api.get(
&Repo::new("Narsil/candle-examples".to_string(), RepoType::Dataset),
&format!("samples_{sample}.wav"),
)?
dataset.get(&format!("samples_{sample}.wav"))?
} else {
std::path::PathBuf::from(input)
}
} else {
println!("No audio file submitted: Downloading https://huggingface.co/datasets/Narsil/candle_demo/blob/main/samples_jfk.wav");
api.get(
&Repo::new("Narsil/candle-examples".to_string(), RepoType::Dataset),
"samples_jfk.wav",
)?
dataset.get("samples_jfk.wav")?
};
(
api.get(&repo, "config.json")?,
api.get(&repo, "tokenizer.json")?,
api.get(&repo, "model.safetensors")?,
repo.get("config.json")?,
repo.get("tokenizer.json")?,
repo.get("model.safetensors")?,
sample,
)
};