Update README.md
Browse files
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: 3D Viewer
|
3 |
-
emoji:
|
4 |
colorFrom: yellow
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.29.0
|
8 |
python_version: 3.12.8
|
@@ -13,7 +13,7 @@ short_description: A very simple 3D ply and glb viewer with link loading
|
|
13 |
hf_oauth: true
|
14 |
fullWidth: true
|
15 |
thumbnail: >-
|
16 |
-
https://cdn-uploads.huggingface.co/production/uploads/6346595c9e5f0fe83fc60444/
|
17 |
---
|
18 |
|
19 |
# 3D Viewer
|
@@ -29,7 +29,21 @@ thumbnail: >-
|
|
29 |
Displays images (height map and source image) using `gr.ImageSlider`. The images are loaded via URL query parameters named `hm` (height map) and `image` (source image).
|
30 |
|
31 |
- **File Upload:**
|
32 |
-
Includes an `gr.UploadButton` for uploading new file types like `.glb`, `.gltf`, `.obj`, `.png`, `.jpg`, and `.ply`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
- **Custom Theming:**
|
35 |
The interface is styled with the `Surn/Beeuty` theme to ensure a modern and cohesive look.
|
@@ -37,7 +51,21 @@ thumbnail: >-
|
|
37 |
## How It Works
|
38 |
|
39 |
- **Query String Parsing:**
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
- **Static Paths:**
|
43 |
The app sets static paths for directories such as `images/`, `models/`, and `assets/` for accessing local resources.
|
@@ -48,7 +76,7 @@ thumbnail: >-
|
|
48 |
|
49 |
Ensure you have Python 3.12.8 installed and install Gradio (v5.29.0 or compatible):
|
50 |
|
51 |
-
```pip install gradio==5.29.0```
|
52 |
|
53 |
|
54 |
2. **Run the Application:**
|
@@ -68,14 +96,25 @@ thumbnail: >-
|
|
68 |
|
69 |
Example URL:
|
70 |
|
71 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
|
|
|
|
73 |
|
74 |
## Project Structure
|
75 |
|
76 |
- **app.py:**
|
77 |
The core application script defining the Gradio interface, callbacks, and dynamic query string processing.
|
78 |
|
|
|
|
|
|
|
79 |
- **README.md:**
|
80 |
This documentation file outlining the project details and configuration.
|
81 |
|
@@ -86,5 +125,4 @@ thumbnail: >-
|
|
86 |
|
87 |
This project is licensed under the Apache-2.0 license.
|
88 |
|
89 |
-
|
90 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
title: 3D Viewer
|
3 |
+
emoji: π
|
4 |
colorFrom: yellow
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.29.0
|
8 |
python_version: 3.12.8
|
|
|
13 |
hf_oauth: true
|
14 |
fullWidth: true
|
15 |
thumbnail: >-
|
16 |
+
https://cdn-uploads.huggingface.co/production/uploads/6346595c9e5f0fe83fc60444/7Dhr01P8ZHeCt1WL2yzZR.png
|
17 |
---
|
18 |
|
19 |
# 3D Viewer
|
|
|
29 |
Displays images (height map and source image) using `gr.ImageSlider`. The images are loaded via URL query parameters named `hm` (height map) and `image` (source image).
|
30 |
|
31 |
- **File Upload:**
|
32 |
+
Includes an `gr.UploadButton` for uploading new file types like `.glb`, `.gltf`, `.obj`, `.png`, `.jpg`, `.jpeg`, `.webp`, and `.ply`.
|
33 |
+
|
34 |
+
- **Permalink Generation:**
|
35 |
+
- Automatically generates a permalink when query parameters are provided in the URL.
|
36 |
+
- Users can also generate a permalink manually after uploading files by clicking the "Generate Permalink" button.
|
37 |
+
- The permalink includes query parameters (`3d`, `hm`, and `image`) to share the current model and images.
|
38 |
+
|
39 |
+
- **Dynamic Button Behavior:**
|
40 |
+
- The "Generate Permalink" button is disabled when a permalink is automatically generated from query parameters.
|
41 |
+
- The button is re-enabled when new files are uploaded, allowing users to generate a new permalink.
|
42 |
+
|
43 |
+
- **HuggingFace Integration:**
|
44 |
+
- Downloads files from HuggingFace repositories using `huggingface_hub.hf_hub_download`.
|
45 |
+
- Supports authentication with HuggingFace via an API token.
|
46 |
+
- Handles nested subfolders and filenames in HuggingFace datasets.
|
47 |
|
48 |
- **Custom Theming:**
|
49 |
The interface is styled with the `Surn/Beeuty` theme to ensure a modern and cohesive look.
|
|
|
51 |
## How It Works
|
52 |
|
53 |
- **Query String Parsing:**
|
54 |
+
The app retrieves query string values (e.g., `3d`, `hm`, `image`) and dynamically loads the corresponding 3D model and images. If query parameters are provided, a permalink is automatically generated and displayed.
|
55 |
+
|
56 |
+
- **Permalink Generation:**
|
57 |
+
- The app uses the `generate_permalink_from_urls` function in `storage.py` to construct a permalink URL with query parameters.
|
58 |
+
- The permalink can be shared to load the same 3D model and images in another session.
|
59 |
+
|
60 |
+
- **File Upload and Permalink Behavior:**
|
61 |
+
- Users can upload files (3D models and images) using the upload button.
|
62 |
+
- After uploading, the "Generate Permalink" button becomes active, allowing users to create a new permalink for the uploaded files.
|
63 |
+
- The permalink includes the uploaded files' URLs.
|
64 |
+
|
65 |
+
- **HuggingFace Downloads:**
|
66 |
+
- The app uses `huggingface_hub.hf_hub_download` to download files from HuggingFace repositories.
|
67 |
+
- It supports nested subfolders and filenames in HuggingFace datasets.
|
68 |
+
- Authentication is handled via the HuggingFace API token.
|
69 |
|
70 |
- **Static Paths:**
|
71 |
The app sets static paths for directories such as `images/`, `models/`, and `assets/` for accessing local resources.
|
|
|
76 |
|
77 |
Ensure you have Python 3.12.8 installed and install Gradio (v5.29.0 or compatible):
|
78 |
|
79 |
+
```pip install gradio==5.29.0 huggingface_hub```
|
80 |
|
81 |
|
82 |
2. **Run the Application:**
|
|
|
96 |
|
97 |
Example URL:
|
98 |
|
99 |
+
```
|
100 |
+
http://localhost:7860/?3d=https://example.com/model.glb&hm=https://example.com/heightmap.png&image=https://example.com/source.png
|
101 |
+
|
102 |
+
https://surn-3d-viewer.hf.space/?3d=https://huggingface.co/datasets/Surn/Storage/resolve/main/dngblfpc3w/scifi_city_3neol7yc_Colorful.ply&hm=https://huggingface.co/datasets/Surn/Storage/resolve/main/dngblfpc3w/scifi_city_3neol7yc_colorful_depth.png&image=https://huggingface.co/datasets/Surn/Storage/resolve/main/dngblfpc3w/scifi_city_3neol7yc_Colorful.png
|
103 |
+
```
|
104 |
+
|
105 |
+
4. **Upload Files and Generate Permalink:**
|
106 |
|
107 |
+
- Use the "Upload 3D Files" button to upload a 3D model and up to two images.
|
108 |
+
- After uploading, click the "Generate Permalink" button to create a shareable link for the uploaded files.
|
109 |
|
110 |
## Project Structure
|
111 |
|
112 |
- **app.py:**
|
113 |
The core application script defining the Gradio interface, callbacks, and dynamic query string processing.
|
114 |
|
115 |
+
- **modules/storage.py:**
|
116 |
+
Contains helper functions for uploading files to HuggingFace repositories and generating permalinks.
|
117 |
+
|
118 |
- **README.md:**
|
119 |
This documentation file outlining the project details and configuration.
|
120 |
|
|
|
125 |
|
126 |
This project is licensed under the Apache-2.0 license.
|
127 |
|
128 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|