Skip to content

Commit baa9109

Browse files
authored
feat: Add Datasets page and DIV2K (#506)
* feat: Add Datasets page and DIV2K * fix: Add missing dataset hooks, components, and API routes to resolve CI build errors * fix: Remove unnecessary conditionals to resolve CI linting warnings * feat: Add Models nav link to header
1 parent ac902e4 commit baa9109

28 files changed

Lines changed: 1801 additions & 32 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "DIV2K dataset: DIVerse 2K",
3+
"author": [
4+
"radu-timofte",
5+
"eirikur-agustsson",
6+
"shuhang-gu",
7+
"jiqing-wu",
8+
"andrey-ignatov",
9+
"luc-van-gool"
10+
],
11+
"license": "Academic-Research-Only",
12+
"tags": [
13+
"dataset:realistic"
14+
],
15+
"description": "The DIV2K dataset is divided into:\n\ntrain data:\nstarting from 800 high definition high resolution images we obtain corresponding low resolution images and provide both high and low resolution images for 2, 3, and 4 downscaling factors\nvalidation data: 100 high definition high resolution images are used for genereting low resolution corresponding images, the low res are provided from the beginning of the challenge and are meant for the participants to get online feedback from the validation server; the high resolution images will be released when the final phase of the challenge starts.\n\ntest data:\n100 diverse images are used to generate low resolution corresponding images; the participants will receive the low resolution images when the final evaluation phase starts and the results will be announced after the challenge is over and the winners are decided.",
16+
"date": "2026-06-15",
17+
"url": "https://data.vision.ee.ethz.ch/cvl/DIV2K/",
18+
"images": [
19+
{
20+
"type": "paired",
21+
"caption": "900",
22+
"LR": "https://i.slow.pics/KWca9Mq7.png",
23+
"SR": "https://i.slow.pics/7P7FzpFq.png"
24+
}
25+
]
26+
}

‎data/tag-categories.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,17 @@
162162
"helper:invalid-scale",
163163
"helper:invalid-channels"
164164
]
165+
},
166+
"dataset": {
167+
"name": "Dataset",
168+
"description": "Tags specific to datasets",
169+
"order": 9,
170+
"simple": true,
171+
"tags": [
172+
"dataset:realistic",
173+
"dataset:anime",
174+
"dataset:manga",
175+
"dataset:game-textures"
176+
]
165177
}
166178
}

‎data/tags.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,22 @@
292292
"name": "RGBA",
293293
"description": "The model upscales images with transparency."
294294
},
295+
"dataset:anime": {
296+
"name": "Anime",
297+
"description": "Anime dataset"
298+
},
299+
"dataset:game-textures": {
300+
"name": "Game Textures",
301+
"description": "Game textures dataset"
302+
},
303+
"dataset:manga": {
304+
"name": "Manga",
305+
"description": "Manga dataset"
306+
},
307+
"dataset:realistic": {
308+
"name": "Realistic",
309+
"description": "Realistic dataset"
310+
},
295311
"helper:invalid-channels": {
296312
"name": "Invalid channels",
297313
"description": "The number of input or output channels of the model is not valid."

‎data/users.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"alsa": {
1515
"name": "Alsa"
1616
},
17+
"andrey-ignatov": {
18+
"name": "Andrey Ignatov"
19+
},
1720
"aptitude": {
1821
"name": "aptitude"
1922
},
@@ -83,6 +86,9 @@
8386
"dinjerr": {
8487
"name": "DinJerr"
8588
},
89+
"eirikur-agustsson": {
90+
"name": "Eirikur Agustsson"
91+
},
8692
"eula": {
8793
"name": "end user license agreement#9756"
8894
},
@@ -128,6 +134,9 @@
128134
"jingyunliang": {
129135
"name": "JingyunLiang"
130136
},
137+
"jiqing-wu": {
138+
"name": "Jiqing Wu"
139+
},
131140
"jixiaozhong": {
132141
"name": "jixiaozhong"
133142
},
@@ -164,6 +173,9 @@
164173
"loinne": {
165174
"name": "Loinne"
166175
},
176+
"luc-van-gool": {
177+
"name": "Luc Van Gool"
178+
},
167179
"lyonhrt": {
168180
"name": "LyonHrt"
169181
},
@@ -218,6 +230,9 @@
218230
"pokepress": {
219231
"name": "pokepress"
220232
},
233+
"radu-timofte": {
234+
"name": "Radu Timofte"
235+
},
221236
"rastrum": {
222237
"name": "Rastrum"
223238
},
@@ -248,6 +263,9 @@
248263
"sharekhan": {
249264
"name": "SharekhaN"
250265
},
266+
"shuhang-gu": {
267+
"name": "Shuhang Gu"
268+
},
251269
"sirosky": {
252270
"name": "Sirosky"
253271
},

‎scripts/validate-db.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs/promises';
22
import path from 'path';
33
import { fileApi } from '../src/lib/server/file-data';
4+
import { validateDataset } from '../src/lib/validate-dataset';
45
import { Report, validateModel } from '../src/lib/validate-model';
56

67
const getAllFiles = async (dir: string): Promise<string[]> => {
@@ -23,6 +24,7 @@ const getAllFiles = async (dir: string): Promise<string[]> => {
2324

2425
const getReports = async (): Promise<Report[]> => {
2526
const modelData = await fileApi.models.getAll();
27+
const datasetData = await fileApi.datasets.getAll();
2628
const architectureData = await fileApi.architectures.getAll();
2729
const tagData = await fileApi.tags.getAll();
2830
const userData = await fileApi.users.getAll();
@@ -31,6 +33,9 @@ const getReports = async (): Promise<Report[]> => {
3133
for (const [modelId, model] of modelData) {
3234
errors.push(...validateModel(model, modelId, modelData, architectureData, tagData, userData, fileApi));
3335
}
36+
for (const [datasetId, dataset] of datasetData) {
37+
errors.push(...validateDataset(dataset, datasetId, fileApi));
38+
}
3439

3540
const jsonFiles = (await getAllFiles('data/')).filter((file) => file.endsWith('.json'));
3641
await Promise.all(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { Dataset, DatasetId } from '../../lib/schema';
3+
import { DatasetCard } from './dataset-card';
4+
import style from './model-card-grid.module.scss';
5+
6+
export interface DatasetCardGridProps {
7+
datasets: readonly (readonly [DatasetId, Dataset])[];
8+
}
9+
10+
export function DatasetCardGrid({ datasets }: DatasetCardGridProps) {
11+
return (
12+
<div className={style.grid}>
13+
{datasets.map(([id, dataset], i) => (
14+
<DatasetCard
15+
dataset={dataset}
16+
id={id}
17+
key={id}
18+
lazy={i >= 12}
19+
/>
20+
))}
21+
</div>
22+
);
23+
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/* eslint-disable @next/next/no-img-element */
2+
/* eslint-disable react/display-name */
3+
import React, { memo, useRef, useState } from 'react';
4+
import { LazyLoadComponent } from 'react-lazy-load-image-component';
5+
import { useDevicePixelRatio } from '../../lib/hooks/use-device-pixel-ratio';
6+
import { useUpdateDataset } from '../../lib/hooks/use-update-dataset';
7+
import { useUsers } from '../../lib/hooks/use-users';
8+
import { useWebApi } from '../../lib/hooks/use-web-api';
9+
import { joinList } from '../../lib/react-util';
10+
import { Dataset, DatasetId, ImageSize, PairedImage } from '../../lib/schema';
11+
import { asArray, assertNever, joinClasses } from '../../lib/util';
12+
import { EditableTags } from './editable-tags';
13+
import { Link } from './link';
14+
import style from './model-card.module.scss';
15+
16+
export interface DatasetCardProps {
17+
id: DatasetId;
18+
dataset: Dataset;
19+
lazy?: boolean;
20+
}
21+
22+
const EMPTY_SIZE: ImageSize = {
23+
height: 0,
24+
width: 0,
25+
};
26+
27+
function getNaturalSize(image: HTMLImageElement): ImageSize {
28+
return {
29+
height: image.naturalHeight,
30+
width: image.naturalWidth,
31+
};
32+
}
33+
34+
const SideBySideImage = ({ datasetName, image }: { datasetName: string; image: PairedImage }) => {
35+
const [lrDimensions, setLrDimensions] = useState(EMPTY_SIZE);
36+
const [srDimensions, setSrDimensions] = useState(EMPTY_SIZE);
37+
38+
const maxHeight = Math.max(lrDimensions.height, srDimensions.height);
39+
const maxWidth = Math.max(lrDimensions.width, srDimensions.width);
40+
41+
const lrRef = useRef<HTMLImageElement>(null);
42+
const srRef = useRef<HTMLImageElement>(null);
43+
44+
const dpr = useDevicePixelRatio();
45+
const scale = (1 / dpr) * Math.max(1, Math.round(dpr + 0.16));
46+
47+
return (
48+
<div className="flex h-full w-full">
49+
<div className="relative flex h-full w-1/2 content-center overflow-hidden align-middle">
50+
<img
51+
alt={datasetName}
52+
className="rendering-pixelated absolute top-1/3 left-1/2 z-0 m-auto object-cover object-center"
53+
loading="lazy"
54+
ref={lrRef}
55+
src={image.LR}
56+
style={{
57+
height: `${maxHeight}px`,
58+
width: `${maxWidth}px`,
59+
transform: `translate(-50%, -50%) scale(${scale})`,
60+
}}
61+
onLoad={(e) => {
62+
setLrDimensions(getNaturalSize(e.target as HTMLImageElement));
63+
}}
64+
/>
65+
</div>
66+
<div className="relative flex h-full w-1/2 content-center overflow-hidden align-middle">
67+
<img
68+
alt={datasetName}
69+
className="rendering-pixelated absolute top-1/3 left-1/2 z-0 m-auto object-cover object-center"
70+
loading="lazy"
71+
ref={srRef}
72+
src={image.SR}
73+
style={{
74+
height: `${maxHeight}px`,
75+
width: `${maxWidth}px`,
76+
transform: `translate(-50%, -50%) scale(${scale})`,
77+
}}
78+
onLoad={(e) => {
79+
setSrDimensions(getNaturalSize(e.target as HTMLImageElement));
80+
}}
81+
/>
82+
</div>
83+
</div>
84+
);
85+
};
86+
87+
const getDatasetCardImageComponent = (dataset: Dataset | undefined) => {
88+
const image = dataset?.images?.[0];
89+
if (!dataset || !image) {
90+
return <div className="margin-auto z-0 w-full py-20 text-center text-gray-500">No Image</div>;
91+
}
92+
switch (image.type) {
93+
case 'paired': {
94+
return (
95+
<SideBySideImage
96+
datasetName={dataset.name}
97+
image={image}
98+
/>
99+
);
100+
}
101+
case 'standalone': {
102+
const imageSrc = image.url;
103+
return (
104+
<img
105+
alt={dataset.name}
106+
className="margin-auto z-0 h-full w-full object-cover"
107+
loading="lazy"
108+
src={imageSrc}
109+
/>
110+
);
111+
}
112+
default:
113+
return assertNever(image);
114+
}
115+
};
116+
117+
const DatasetCardContent = memo(({ id, dataset }: DatasetCardProps) => {
118+
const { userData } = useUsers();
119+
const { webApi, editMode } = useWebApi();
120+
const { updateDatasetProperty } = useUpdateDataset(webApi, id);
121+
122+
const isPaired = dataset.images?.[0]?.type === 'paired' && !editMode;
123+
124+
return (
125+
<div className={style.inner}>
126+
<Link
127+
className={joinClasses(style.thumbnail, isPaired && style.paired, 'bg-fade-300 dark:bg-fade-700 ')}
128+
href={`/datasets/${id}`}
129+
tabIndex={-1}
130+
>
131+
{getDatasetCardImageComponent(dataset)}
132+
</Link>
133+
134+
<div className={joinClasses(style.details, isPaired && style.paired)}>
135+
<Link
136+
className={`${style.name} block text-xl font-bold text-gray-800 dark:text-gray-100`}
137+
href={`/datasets/${id}`}
138+
>
139+
{dataset.name}
140+
</Link>
141+
<div className="text-sm text-gray-600 dark:text-gray-400">
142+
{'by '}
143+
{joinList(
144+
asArray(dataset.author).map((userId) => (
145+
<Link
146+
className="font-bold text-accent-600 dark:text-accent-400"
147+
href={`/users/${userId}`}
148+
key={userId}
149+
>
150+
{userData.get(userId)?.name ?? `unknown user:${userId}`}
151+
</Link>
152+
))
153+
)}
154+
</div>
155+
156+
{/* Description */}
157+
<div className="mb-2 mt-1 text-sm text-gray-600 line-clamp-3 dark:text-gray-400">
158+
{dataset.description}
159+
</div>
160+
161+
{/* Tags */}
162+
<div className="flex flex-row flex-wrap gap-1 text-xs">
163+
<EditableTags
164+
readonly={!editMode}
165+
tags={dataset.tags}
166+
onChange={(tags) => updateDatasetProperty('tags', tags)}
167+
/>
168+
</div>
169+
</div>
170+
</div>
171+
);
172+
});
173+
174+
export const DatasetCard = memo(({ id, dataset, lazy = false }: DatasetCardProps) => {
175+
const { editMode } = useWebApi();
176+
177+
const inner = (
178+
<div
179+
className={joinClasses(
180+
style.modelCard,
181+
!editMode && style.overflowHidden,
182+
'border-gray-300 bg-white shadow-lg hover:shadow-2xl dark:border-gray-700 dark:bg-fade-900'
183+
)}
184+
>
185+
<DatasetCardContent
186+
dataset={dataset}
187+
id={id}
188+
/>
189+
</div>
190+
);
191+
192+
if (!lazy) return inner;
193+
194+
return (
195+
<LazyLoadComponent
196+
placeholder={
197+
<div
198+
className={`${style.modelCard} border-gray-300 bg-white shadow-lg hover:shadow-2xl dark:border-gray-700 dark:bg-fade-900`}
199+
/>
200+
}
201+
>
202+
{inner}
203+
</LazyLoadComponent>
204+
);
205+
});

0 commit comments

Comments
 (0)