Giter Site home page Giter Site logo

gitctrlx / narrativecanvas Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 0.0 96.78 MB

"Narrative Canvas" project is an edge computing project based on Nvidia Jetson. It can transform uploaded images into captivating stories and artworks.

Python 55.83% Dockerfile 0.20% Shell 0.16% JavaScript 13.82% CSS 4.39% HTML 25.61%
edge-computing jetson tensorrt-inference

narrativecanvas's Introduction

Narrative Canvas: Image-Inspired Storytelling

Narrative Canvas, also known as "Language Within the Paintings," is the very essence of this project. Here, each canvas is not merely a combination of colors and lines but a collection of untold stories waiting to be discovered. Artists unleash their imaginations onto the canvas, and every stroke and every brushstroke carries profound emotions and a unique perspective. These artworks, akin to poems without words, quietly narrate their own tales.

This project has successfully implemented image inference tasks, text generation tasks, and image generation tasks on the Jetson development board. It utilizes TensorRT for accelerated inference and Flask to run the UI page. This project was awarded first place in the Nvidia 9th Sky Hackathon competition.

Demonstration

Video Demonstration Link: https://www.bilibili.com/video/BV1rc411D7pP

The entire project workflow can be divided into the following steps:

  1. Image Inference
  2. Story Generation
  3. Image Generation

image-20231205130800981

Prerequisites

Prepare Model && Calibration Data

ONNX

Our project models are based on the mmpretrain pre-trained models from the mmlab algorithm library. We have carefully selected 25 classic backbone networks for the image classification task in this project. We also provide scripts for converting PyTorch (pt) models to ONNX models, including the recent work on EfficientVit. Additionally, we offer conversion scripts to export ONNX models in Dynamic Shape mode.

We provide both preprocessed ONNX models using Polygraphy and the original exported ONNX model files, You can choose to download it from Google Drive or Hugging Face.

Please place the downloaded ONNX file into the models/onnx directory.

Calibdata

Our calibration dataset consists of 510 images selected from the ImageNet 1K validation dataset. We also provide a download link for the calibration dataset.

Please place the downloaded calibdata file into the models/calibdata directory.

Prepare API

Before running this project, you need to prepare the Nvidia NGC llama2-70b-steerlm API and the Nvidia NGC Stable Diffusion XL API and fill in their details in the config.json file. You can also fill in your Azure OpenAI API key in the config.json if you have one, but this is not mandatory.

"sdxl": {
    "invoke_url": "" ,
    "fetch_url_format": "",
    "headers": {
        "Authorization": "",
        "Accept": ""
    }
},
"llama2": {
    "invoke_url": "",
    "fetch_url_format": "",
    "headers": {
        "Authorization": "",
        "Accept": ""
    }
},
"azure_openai":{
    "api_key": "",
    "api_base": "",
    "deployment_name": "",
    "api_version": ""
}

Setup Runtime Environment

We provide two methods for building the runtime environment for different hardware environments. One is deploying the environment using Nvidia Container on Windows or Linux, and the other is configuring the environment using pip on a Jetson Orin development board.

  • Nvidia Container

  • Nvidia Jetson Orin

    • Jetpack 5.1.2 (Jetson Linux 35.4.1 + TensorRT 8.5.2 + DLA 3.12.1 + cuDNN 8.6.0 + CUDA 11.4.19)

Note: If you are using the Jetson Xavier NX hardware platform, please refer to this project: https://github.com/1438802682/NarrativeCanvas-JetsonXavierNX

Windows && Linux

We provide a Dockerfile to ease environment setup. Please execute the following command to build the docker image after nvidia-docker installation:

docker build -t sky docker

Jetson Orin

Before building the runtime environment on the Jetson Orin platform, please upgrade the Jetson Orin's JetPack environment version to 5.1.2, and then execute the following command:

pip3 install requirements.txt

Run

We can then run the docker with the following command:

Windows && Linux

  • Windows:
docker run --gpus all --rm -it -p 3008:3008 -v %cd%:/sky sky

Note: When you start the sky container with the default command mentioned above, it automatically executes the following command: gunicorn -b 0.0.0.0:3008 app:app. Alternatively, you can also use the following command to start the container using Flask's default command. Using Gunicorn to deploy our application can achieve higher performance.

docker run --gpus all --rm -it -p 3008:3008 -v %cd%:/sky sky flask run --host=0.0.0.0 --port=3008
  • Linux:
docker run --gpus all --rm -it -p 3008:3008 -v $PWD:/sky sky

After you have completed the steps above, please visit http://127.0.0.1:3008/ to embark on your creative journey!

Jetson Orin

gunicorn -b 127.0.0.1:3008 app:app

After you have completed the steps above, please visit http://127.0.0.1:3008/ to embark on your creative journey!

Note

Demonstration Sample

image-20231205130723783

image-20231205130713558

UI Prototype

Project Architecture Diagram

Flowchart

  • If you encounter any issues or would like to obtain more technical details, please feel free to contact me at [email protected]

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.