GithubHelp home page GithubHelp logo

whuhxb / shap-e-local Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kedzkiest/shap-e-local

0.0 0.0 0.0 11.71 MB

The procedure and the code to run shap-e sample code locally.

License: MIT License

Python 98.27% Jupyter Notebook 1.73%

shap-e-local's Introduction

Shap-E-local

The code to run shap-e text-to-3d sample code locally.
The original code is available at (https://github.com/openai/shap-e/blob/main/shap_e/examples/sample_text_to_3d.ipynb)

Why I make this project?

One nice thing about being able to run code locally is that 3D models can be generated without an Internet connection.

For this reason, I created this project as a sample for those who want to generate 3D models offline, or for those who are looking for a place to boast their ample GPU power.

Demo

I imported the 3D models (.obj) generated by the following prompts into Blender and rendered them:

  • an apple
  • a shark
  • a table

The walls and the floor is blender's built-in plane object. shap-e_test

Environments

OS: Ubuntu 20.04.5 LTS
CPU: Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz
GPU: NVIDIA GeForce RTX 3090
Cuda version: 12.1
pip version: 23.1.2
conda version: 23.5.0

Procedure

1. Download this project as a zip folder, then unzip it

2. Create a virtual environment using Anaconda, then activate it

conda create -n shap-e python=3.10
conda activate shap-e

3. Change your current directory to unzipped folder

// example
cd shap-e-local-main

4. Install required libraries

pip install -e .
pip install pyyaml ipywidgets fvcore iopath

5. Run testTorch.py to confirm torch is recognizing cuda

python testTorch.py

If the output of this program looks like this, you are okay to go:

PyTorch is using: cuda  
PyTorch version: 2.0.1+cu117  
Result of tensor operation: tensor([ 8., 15.], device='cuda:0')  

6. Run pytorch3dPrep.py to check suitable version of pytorch3d

python pytorch3dPrep.py

This program output a string ("py310_cu117_pyt201", for example)
Remember this string.

7. Install pytorch3d library

pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{output string}/download.html

// example
pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py310_cu117_pyt201/download.html

8. Finally, let's generate a 3D model!

Before running the code below, you can edit textTo3D.py to change the input text prompt, batch_size, etc.

python textTo3D.py

This program outputs some .obj files and .ply files according to the batch_size you specified.

9. For those who want to see a preview of generated 3D models..

First install required libraries to display 3D objects.

pip install vedo
pip install open3d

Then, use the commands below to inspect generated files.
(command line argument "filepath" is the path of a file except file extension part.
e.g. you type "python displayPly.py output/mesh_0" to inspect "output/mesh_0.ply" file.)

python displayObj.py {filepath}
python displayPly.py {filepath}

shap-e-local's People

Contributors

kedzkiest avatar

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.