Skip to content
30 changes: 15 additions & 15 deletions examples/generative/fine_tune_via_textual_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def assemble_dataset(urls, prompts):
"""

train_ds = assemble_dataset(
urls=[
"https://i.imgur.com/VIedH1X.jpg",
"https://i.imgur.com/eBw13hE.png",
"https://i.imgur.com/oJ3rSg7.png",
"https://i.imgur.com/5mCL6Df.jpg",
"https://i.imgur.com/4Q6WWyI.jpg",
urls=[
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/1.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/2.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/3.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/4.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/1.jpeg",
],
prompts=[
"a photo of a {}",
Expand Down Expand Up @@ -232,12 +232,12 @@ def assemble_dataset(urls, prompts):
"""

single_ds = assemble_dataset(
urls=[
"https://i.imgur.com/VIedH1X.jpg",
"https://i.imgur.com/eBw13hE.png",
"https://i.imgur.com/oJ3rSg7.png",
"https://i.imgur.com/5mCL6Df.jpg",
"https://i.imgur.com/4Q6WWyI.jpg",
urls=[
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/1.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/2.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/3.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/4.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/1.jpeg",
],
prompts=[
"a photo of a {}",
Expand Down Expand Up @@ -278,9 +278,9 @@ def assemble_dataset(urls, prompts):

group_ds = assemble_dataset(
urls=[
"https://i.imgur.com/yVmZ2Qa.jpg",
"https://i.imgur.com/JbyFbZJ.jpg",
"https://i.imgur.com/CCubd3q.jpg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/6.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/7.jpeg",
"https://huggingface.co/datasets/diffusers/cat_toy_example/resolve/main/3.jpeg",
],
prompts=[
"a photo of a group of {}",
Expand Down
11 changes: 8 additions & 3 deletions examples/generative/neural_style_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@
import tensorflow as tf
from keras.applications import vgg19

base_image_path = keras.utils.get_file("paris.jpg", "https://i.imgur.com/F28w3Ac.jpg")
base_image_path = keras.utils.get_file(
"YellowLabradorLooking_new.jpg",
"https://storage.googleapis.com/download.tensorflow.org/example_images/YellowLabradorLooking_new.jpg",
)
style_reference_image_path = keras.utils.get_file(
"starry_night.jpg", "https://i.imgur.com/9ooB60I.jpg"
"starry_night.jpg",
"https://raw.githubusercontent.com/jcjohnson/neural-style/master/examples/inputs/starry_night.jpg",
)
result_prefix = "paris_generated"
# ✅ NEW
result_prefix = "style_transfer_result"

# Weights of the different loss components
total_variation_weight = 1e-6
Expand Down
8 changes: 6 additions & 2 deletions examples/timeseries/timeseries_traffic_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@
"""

url = "https://github.com/VeritasYin/STGCN_IJCAI-18/raw/master/dataset/PeMSD7_Full.zip"
data_dir = keras.utils.get_file(origin=url, extract=True, archive_format="zip")
data_dir = data_dir.rstrip("PeMSD7_Full.zip")
# 1. Download and extract normally
zip_path = keras.utils.get_file(origin=url, extract=True, archive_format="zip")

# 2. FIX: Use os.path.dirname to safely get the folder where it was extracted
data_dir = os.path.dirname(zip_path)

# 3. Construct the paths to the inner files safely
route_distances = pd.read_csv(
os.path.join(data_dir, "PeMSD7_W_228.csv"), header=None
).to_numpy()
Expand Down
12 changes: 9 additions & 3 deletions examples/timeseries/timeseries_weather_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
## Setup
"""

import os
import pandas as pd
import matplotlib.pyplot as plt
import keras
Expand Down Expand Up @@ -50,13 +50,19 @@
15 |wd (deg) |152.3 |Wind direction in degrees
"""



from zipfile import ZipFile

uri = "https://storage.googleapis.com/tensorflow/tf-keras-datasets/jena_climate_2009_2016.csv.zip"
zip_path = keras.utils.get_file(origin=uri, fname="jena_climate_2009_2016.csv.zip")
zip_file = ZipFile(zip_path)
zip_file.extractall()
csv_path = "jena_climate_2009_2016.csv"

# FIX: Extract to the cache directory, not the current working directory
zip_file.extractall(path=os.path.dirname(zip_path))

# FIX: Construct the absolute path safely (works on Windows/Linux/Mac)
csv_path = os.path.join(os.path.dirname(zip_path), "jena_climate_2009_2016.csv")

df = pd.read_csv(csv_path)

Expand Down
4 changes: 2 additions & 2 deletions examples/vision/grad_cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

# The local path to our target image
img_path = keras.utils.get_file(
"african_elephant.jpg", "https://i.imgur.com/Bvro0YD.png"
"YellowLabradorLooking_new.jpg",
"https://storage.googleapis.com/download.tensorflow.org/example_images/YellowLabradorLooking_new.jpg",
)

display(Image(img_path))


Expand Down