Skip to content

Commit

Permalink
added skipTextures option
Browse files Browse the repository at this point in the history
  • Loading branch information
cpietsch committed May 1, 2023
1 parent a3bf935 commit 6a972da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

The script in /images will generate textures and spritesheet assets which are needed for the [vikus-viewer](https://github.com/cpietsch/vikus-viewer) (repo). The script in /tsne will generate a TSNE layout which can be used as an alternative to the timeline-view in VIKUS Viewer.


## Requirements

- nodejs
- use the installer on https://nodejs.org/en/download/
- or use nvm https://github.com/creationix/nvm


## Usage image script

Install the script as a command line tool without the need of cloning / downloading:
Expand All @@ -17,15 +16,15 @@ Install the script as a command line tool without the need of cloning / download
npm install -g vikus-viewer-script
```

Alternatively you can download or clone this repo and install the required node packages:
Alternatively you can download or clone this repo and install the required node packages:

```sh
git clone https://github.com/cpietsch/vikus-viewer-script
cd vikus-viewer-script
npm install
```
Note: You can run the script via `node bin/textures` instead of `vikus-viewer-script` if you have cloned it.

Note: You can run the script via `node bin/textures` instead of `vikus-viewer-script` if you have cloned it.

All your images should be in one folder (lets say "images") and named x.jpg where x is the id of the image corresponding to the id field in data.csv

Expand All @@ -43,18 +42,20 @@ You are now finished in preparing the textures and spritesheets!

Copy the folder 1024, 4096 and sprites inside data into your /data folder of your [vikus-viewer](https://github.com/cpietsch/vikus-viewer) instance. After a successful run you can delete the tmp folder.

*A note for collections of 5000+ items*: In the default configuration the script will generate sprites at the maximum dimensions of 256x256px. For faster loading time and collections with a lot of items, you should adjust the resolution of the sprites by running changing the ``--spriteSize`` flag to e.g. 90.
_A note for collections of 5000+ items_: In the default configuration the script will generate sprites at the maximum dimensions of 256x256px. For faster loading time and collections with a lot of items, you should adjust the resolution of the sprites by running changing the `--spriteSize` flag to e.g. 90.

### Examples:

#### Create textures

```sh
vikus-viewer-script "/path/to/your/images/*.jpg" # on jpg's
vikus-viewer-script "/path/to/your/images/*.+(jpg|jpeg|png)" # on multiple formats
vikus-viewer-script "/path/to/your/images/**/*.jpg" # on all jpg's in subfolders
```

### CLI commands

```sh
Usage: vikus-viewer-script "/path/to/large/images/*.jpg" [options]

Expand All @@ -73,17 +74,19 @@ Options:
--spriteFormat spritesheets format (jpg or png) [default: "jpg"]
--largeSize resolution of full sized images [default: 4096]
--mediumSize resolution of images loaded on the fly [default: 1024]
--skipTextures skip texture generation, only make spritesheets
[default: false]
-h, --help Show help [boolean]
Examples:
vikus-viewer-script "/path/to/large/images/*.jpg" create VV textures from jpgs
```
```
## Usage t-SNE/UMAP script
As an alternative to the temporal view, you can create a t-SNE layout based on image similarity. The script creates a tsne.csv which can be put next to the data.csv in the /data folder. Image similarity is calculated via the [mobilenet activation logit](https://beta.observablehq.com/@cpietsch/imagenet-activation-logit) and then run throught t-SNE or UMAP. An additional spacing step ensures no overlaying images in the distribution.
Download or clone this repo, navigate to /similarity and install the required node packages:
Download or clone this repo, navigate to /similarity and install the required node packages:
```sh
cd /similarity
Expand All @@ -93,6 +96,7 @@ npm i
Add the `-t` flag to the script to use the much faster tfjs-node implementation instead of the default tfjs.
Run the t-SNE script:
```sh
node tsne.js -i /path/to/images
```
Expand Down
9 changes: 4 additions & 5 deletions bin/textures
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ const argv = require("yargs")
.default("spriteQuality", 70)
.describe("spriteFormat", "spritesheets format (jpg or png)")
.default("spriteFormat", "jpg")
.describe("largeSize", "resolution of full sized images, (0 to disable)")
.describe("largeSize", "resolution of full sized images")
.default("largeSize", 4096)
.describe(
"mediumSize",
"resolution of images loaded on the fly, (0 to disable)"
)
.describe("mediumSize", "resolution of images loaded on the fly")
.default("mediumSize", 1024)
.describe("skipTextures", "skip texture generation, only make spritesheets")
.default("skipTextures", false)
.help("h")
.alias("h", "help").argv;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vikus-viewer-script",
"version": "2.0.5",
"version": "2.0.6",
"description": "Preprocessing scripts for vikus-viewer",
"author": {
"name": "Christopher Pietsch",
Expand Down
11 changes: 6 additions & 5 deletions src/textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const cascade = require("./cascade.js");
const sharpsheet = require("sharpsheet");

exports.run = async function textures(inputPath, options) {
const skipTextures = options.skipTextures || false;
const textureRes1 = options.largeSize || 4096;
const textureRes2 = options.mediumSize || 1024;
const textureRes3 = options.spriteSize || 128;
Expand All @@ -19,20 +20,20 @@ exports.run = async function textures(inputPath, options) {
const spritesPath = createPath(workPath + "/sprites");
const tmpPath = createPath(workPath + "/tmp");
const textureRes1Path =
textureRes1 && createPath(workPath + "/" + textureRes1);
!skipTextures && createPath(workPath + "/" + textureRes1);
const textureRes2Path =
textureRes2 && createPath(workPath + "/" + textureRes2);
!skipTextures && createPath(workPath + "/" + textureRes2);
const textureRes3Path = createPath(tmpPath + "/" + textureRes3);

const resizeSteps = [
textureRes1 && {
!skipTextures && {
width: textureRes1,
height: textureRes1,
format: textureFormat,
quality: textureQuality,
path: textureRes1Path,
},
textureRes2 && {
!skipTextures && {
width: textureRes2,
height: textureRes2,
format: textureFormat,
Expand All @@ -46,7 +47,7 @@ exports.run = async function textures(inputPath, options) {
quality: 100,
path: textureRes3Path,
},
];
].filter((s) => s);

console.log("\nlooking for images at ", inputPath);

Expand Down

0 comments on commit 6a972da

Please sign in to comment.