Razikus osanseviero HF staff commited on
Commit
334768d
0 Parent(s):

Duplicate from openai/point-e

Browse files

Co-authored-by: Omar Sanseviero <osanseviero@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +86 -0
  4. requirements.txt +2 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Point E
3
+ emoji: 🌖
4
+ colorFrom: purple
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 3.14.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: openai/point-e
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import plotly.graph_objects as go
3
+
4
+ import torch
5
+ from tqdm.auto import tqdm
6
+
7
+ from point_e.diffusion.configs import DIFFUSION_CONFIGS, diffusion_from_config
8
+ from point_e.diffusion.sampler import PointCloudSampler
9
+ from point_e.models.download import load_checkpoint
10
+ from point_e.models.configs import MODEL_CONFIGS, model_from_config
11
+ from point_e.util.plotting import plot_point_cloud
12
+
13
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
14
+
15
+ print('creating base model...')
16
+ base_name = 'base40M-textvec'
17
+ base_model = model_from_config(MODEL_CONFIGS[base_name], device)
18
+ base_model.eval()
19
+ base_diffusion = diffusion_from_config(DIFFUSION_CONFIGS[base_name])
20
+
21
+ print('creating upsample model...')
22
+ upsampler_model = model_from_config(MODEL_CONFIGS['upsample'], device)
23
+ upsampler_model.eval()
24
+ upsampler_diffusion = diffusion_from_config(DIFFUSION_CONFIGS['upsample'])
25
+
26
+ print('downloading base checkpoint...')
27
+ base_model.load_state_dict(load_checkpoint(base_name, device))
28
+
29
+ print('downloading upsampler checkpoint...')
30
+ upsampler_model.load_state_dict(load_checkpoint('upsample', device))
31
+
32
+ sampler = PointCloudSampler(
33
+ device=device,
34
+ models=[base_model, upsampler_model],
35
+ diffusions=[base_diffusion, upsampler_diffusion],
36
+ num_points=[1024, 4096 - 1024],
37
+ aux_channels=['R', 'G', 'B'],
38
+ guidance_scale=[3.0, 0.0],
39
+ model_kwargs_key_filter=('texts', ''), # Do not condition the upsampler at all
40
+ )
41
+
42
+ def inference(prompt):
43
+ samples = None
44
+ for x in sampler.sample_batch_progressive(batch_size=1, model_kwargs=dict(texts=[prompt])):
45
+ samples = x
46
+ pc = sampler.output_to_point_clouds(samples)[0]
47
+ pc = sampler.output_to_point_clouds(samples)[0]
48
+ colors=(238, 75, 43)
49
+ fig = go.Figure(
50
+ data=[
51
+ go.Scatter3d(
52
+ x=pc.coords[:,0], y=pc.coords[:,1], z=pc.coords[:,2],
53
+ mode='markers',
54
+ marker=dict(
55
+ size=2,
56
+ color=['rgb({},{},{})'.format(r,g,b) for r,g,b in zip(pc.channels["R"], pc.channels["G"], pc.channels["B"])],
57
+ )
58
+ )
59
+ ],
60
+ layout=dict(
61
+ scene=dict(
62
+ xaxis=dict(visible=False),
63
+ yaxis=dict(visible=False),
64
+ zaxis=dict(visible=False)
65
+ )
66
+ ),
67
+ )
68
+ return fig
69
+
70
+ demo = gr.Interface(
71
+ fn=inference,
72
+ inputs="text",
73
+ outputs=gr.Plot(),
74
+ examples=[
75
+ ["a red motorcycle"],
76
+ ["a RED pumpkin"],
77
+ ["a yellow rubber duck"]
78
+ ],
79
+ title="Point-E demo: text to 3D",
80
+ description="""Generated 3D Point Cloiuds with [Point-E](https://github.com/openai/point-e/tree/main). This demo uses a small, worse quality text-to-3D model to produce 3D point clouds directly from text descriptions.
81
+ Skip the queue by duplicating this space and upgrading to GPU in settings
82
+ <a href="https://huggingface.co/spaces/openai/point-e?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>
83
+ """
84
+ )
85
+ demo.queue(max_size=30)
86
+ demo.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ git+https://github.com/openai/point-e
2
+ plotly