Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add STL 3D model support #7049

Merged
merged 8 commits into from Jan 19, 2024
Merged

add STL 3D model support #7049

merged 8 commits into from Jan 19, 2024

Conversation

Mon-ius
Copy link
Contributor

@Mon-ius Mon-ius commented Jan 17, 2024

Since V4 supports adding .STL file in examples path which can render correctly in the box. There is no need to limit ".stl" file in the accepted upload list.

Example code:

import numpy as np
import gradio as gr
import trimesh, os

def load_mesh(mesh_file_name):
    return mesh_file_name

print(
    os.path.join(os.path.dirname(os.path.dirname(__file__)), "dataset/1/output_0.stl")
)

T3D = gr.Interface(
    fn=load_mesh,
    inputs=gr.Model3D(label="3D Mesh File"),
    outputs=gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model"),
    examples=[
        [os.path.join(os.path.dirname(os.path.dirname(__file__)), "dataset/1/output_0.stl")],
        [os.path.join(os.path.dirname(os.path.dirname(__file__)), "dataset/2/output_0.stl")],
        [os.path.join(os.path.dirname(os.path.dirname(__file__)), "dataset/3/output_0.stl")],
    ],
    cache_examples=True,
)

T3D.launch(share=False)

Adding STL support can contribute a lot to 3D print industry, without extra convert, people can play more seamless 🤗

For more details, see https://huggingface.co/spaces/MassiveDL/T3D

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 17, 2024

🪼 branch checks and previews

Name Status URL
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details
📓 Notebooks not matching! Details

The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes:

pip install nbformat && cd demo && python generate_notebooks.py

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Jan 17, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/model3d minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

add STL 3D model support

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@freddyaboulton
Copy link
Collaborator

Thanks @Mon-ius ! I think this looks good to me! Tagging @dawoodkhan82 @hannahblair for quick review from them.

@Mon-ius
Copy link
Contributor Author

Mon-ius commented Jan 18, 2024

Great! Some checks need external auth for vercel deploy failed, should not be a problem!

Copy link
Collaborator

@dawoodkhan82 dawoodkhan82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! tested, and works. It would be great, if you can update the model3D demo to include a .stl example.

@Mon-ius
Copy link
Contributor Author

Mon-ius commented Jan 19, 2024

@dawoodkhan82 No problem! I will update a new model3D demo with .STL format file 🤗

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Mon-ius ! I added the stl file to the existing model3D demo as opposed to creating a new one. Will merge once CI passes!

@freddyaboulton freddyaboulton merged commit 1718c4a into gradio-app:main Jan 19, 2024
10 of 15 checks passed
@pngwn pngwn mentioned this pull request Jan 19, 2024
@Mon-ius
Copy link
Contributor Author

Mon-ius commented Jan 20, 2024

@freddyaboulton Good Job! Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants