Update model.py
Browse files
model.py
CHANGED
|
@@ -13,6 +13,13 @@ from shap_e.rendering.torch_mesh import TorchMesh
|
|
| 13 |
from shap_e.util.collections import AttrDict
|
| 14 |
from shap_e.util.image_util import load_image
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Copied from https://github.com/openai/shap-e/blob/d99cedaea18e0989e340163dbaeb4b109fa9e8ec/shap_e/util/notebooks.py#L15-L42
|
| 18 |
def create_pan_cameras(size: int,
|
|
@@ -97,13 +104,15 @@ class Model:
|
|
| 97 |
return mesh_path.name
|
| 98 |
|
| 99 |
def run_text(self,
|
| 100 |
-
|
| 101 |
seed: int = 0,
|
| 102 |
guidance_scale: float = 15.0,
|
| 103 |
num_steps: int = 64) -> str:
|
| 104 |
self.load_model('text300M')
|
| 105 |
torch.manual_seed(seed)
|
| 106 |
|
|
|
|
|
|
|
| 107 |
latents = sample_latents(
|
| 108 |
batch_size=1,
|
| 109 |
model=self.model_text,
|
|
|
|
| 13 |
from shap_e.util.collections import AttrDict
|
| 14 |
from shap_e.util.image_util import load_image
|
| 15 |
|
| 16 |
+
caption = gr.load(name="spaces/fffiloni/CoCa-clone")
|
| 17 |
+
|
| 18 |
+
def create_image_caption(image_init):
|
| 19 |
+
cap = caption(image_init, "Beam search", 1.2, 0.5, 5, 20, fn_index=0)
|
| 20 |
+
print("cap: " + cap)
|
| 21 |
+
return cap
|
| 22 |
+
|
| 23 |
|
| 24 |
# Copied from https://github.com/openai/shap-e/blob/d99cedaea18e0989e340163dbaeb4b109fa9e8ec/shap_e/util/notebooks.py#L15-L42
|
| 25 |
def create_pan_cameras(size: int,
|
|
|
|
| 104 |
return mesh_path.name
|
| 105 |
|
| 106 |
def run_text(self,
|
| 107 |
+
image: str,
|
| 108 |
seed: int = 0,
|
| 109 |
guidance_scale: float = 15.0,
|
| 110 |
num_steps: int = 64) -> str:
|
| 111 |
self.load_model('text300M')
|
| 112 |
torch.manual_seed(seed)
|
| 113 |
|
| 114 |
+
prompt = create_image_caption(image)
|
| 115 |
+
|
| 116 |
latents = sample_latents(
|
| 117 |
batch_size=1,
|
| 118 |
model=self.model_text,
|