Jina “Hello, World!” 👋🌍

As a starter, we invite you to try Jina’s “Hello, World” - a simple demo of image neural search for [Fashion-MNIST](https://hanxiao.io/2018/09/28/Fashion-MNIST-Year-In-Review/). No extra dependencies needed, simply do:

jina hello-world

…or even easier for Docker users, no any install required, simply:

docker run -v "$(pwd)/j:/j" jinaai/jina:devel hello-world --workdir /j --logserver && open j/hello-world.html
../../_images/hello-world-demo.png

It downloads Fashion-MNIST training and test data and tells Jina to index 60,000 images from the training set. Then, it randomly samples images from the test set as queries, asks Jina to retrieve relevant results. After about 1 minute, it will open a webpage and show results like this:

../../_images/hello-world.gif

And the implementation behind? As simple as it should be:

Python API
from jina.flow import Flow

f = Flow.load_config('index.yml')

with f:
    f.index(input_fn)
YAML spec
!Flow
pods:
  chunk_seg:
    yaml_path: helloworld.crafter.yml
    replicas: $REPLICAS
    read_only: true
  doc_idx:
    yaml_path: helloworld.indexer.doc.yml
  encode:
    yaml_path: helloworld.encoder.yml
    needs: chunk_seg
    replicas: $REPLICAS
  chunk_idx:
    yaml_path: helloworld.indexer.chunk.yml
    replicas: $SHARDS
    separated_workspace: true
  join_all:
    yaml_path: _merge
    needs: [doc_idx, chunk_idx]
    read_only: true
Flow in Dashboard
../../_images/hello-world-flow.png

All big words you can name: computer vision, neural IR, microservice, message queue, elastic, replicas & shards happened in just one minute!

View “Hello World” in Jina Dashboard

pip install "jina[sse]"

jina hello-world --logserver

or if you use Docker:

docker run -p 5000:5000 -v $(pwd)/tmp:/workspace jinaai/jina:devel hello-world --workdir /workspace --logserver && open tmp/hello-world.html

More Options on “Hello, World”

Intrigued? Play with different options via:

jina hello-world --help

Start the hello-world demo, a simple end2end image index and search demo without any extra dependencies.

usage: jina hello-world [-h] [--workdir] [--logserver] [--logserver-config]
                        [--download-proxy] [--shards] [--replicas]
                        [--index-yaml-path] [--index-data-url]
                        [--index-batch-size] [--query-yaml-path]
                        [--query-data-url] [--query-batch-size] [--num-query]
                        [--top-k]

general arguments

--workdir

the workdir for hello-world demo, all data, indices, shards and outputs will be saved there

Default: “e3a6141ca5”

--logserver

start a log server for the dashboard

Default: False

--logserver-config

the yaml config of the log server

Default: “/home/runner/work/jina/jina/jina/resources/logserver.default.yml”

--download-proxy

specify the proxy when downloading sample data

scalability arguments

--shards

number of shards when index and query

Default: 2

--replicas

number of replicas when index and query

Default: 2

index arguments

--index-yaml-path

the yaml path of the index flow

Default: “/home/runner/work/jina/jina/jina/resources/helloworld.flow.index.yml”

--index-data-url

the url of index data (should be in idx3-ubyte.gz format)

Default: “http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz

--index-batch-size

the batch size in indexing

Default: 1024

query arguments

--query-yaml-path

the yaml path of the query flow

Default: “/home/runner/work/jina/jina/jina/resources/helloworld.flow.query.yml”

--query-data-url

the url of query data (should be in idx3-ubyte.gz format)

Default: “http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz

--query-batch-size

the batch size in searching

Default: 32

--num-query

number of queries to visualize

Default: 128

--top-k

top-k results to retrieve and visualize

Default: 50