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

feat: support hff mesh ingestion #234

Merged
merged 83 commits into from
Sep 4, 2024
Merged

feat: support hff mesh ingestion #234

merged 83 commits into from
Sep 4, 2024

Conversation

Bento007
Copy link
Contributor

@Bento007 Bento007 commented Aug 29, 2024

Relates to chanzuckerberg/cryoet-data-portal#951
Blocked by #209

Description

  • add support for ingest the hff mesh ingest format.
  • add mesh_name to identify what mesh to extract from the hff file. This is because the hff format can store more than one mesh
  • add AbstractTriangularMeshAnnotation to contain shared members across classes.
  • Add TriangularMeshAnnotationGroup to ingest a mesh annotation where the mesh is stored among multiple meshes.
  • Add script to generate test hff data from a .glb mesh file. This is for reproducibility in the future if new test data needs to be generated.
  • Added unit test for TriangularMeshAnnotationGroup.
  • Update the ingestion_config schema with

Testing

  • added unit tests
  • tested with a real hff file and verified the generated hff had the same types and general structure.

Bento007 and others added 30 commits August 7, 2024 12:50
# Conflicts:
#	ingestion_tools/poetry.lock
#	ingestion_tools/pyproject.toml
#	ingestion_tools/scripts/importers/annotation.py
#	ingestion_tools/scripts/tests/s3_import/test_annotations.py
- include tests cases
- support ingesting glb format
# Conflicts:
#	ingestion_tools/dataset_configs/template.yaml
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models.schema.json
@Bento007 Bento007 requested a review from manasaV3 August 29, 2024 21:51
Base automatically changed from tsmith/951-ingest-mesh to main August 30, 2024 18:51
# Conflicts:
#	ingestion_tools/dataset_configs/template.yaml
#	ingestion_tools/poetry.lock
#	ingestion_tools/pyproject.toml
#	ingestion_tools/scripts/common/mesh_converter.py
#	ingestion_tools/scripts/importers/annotation.py
#	ingestion_tools/scripts/tests/s3_import/test_annotations.py
#	schema/api/v1.0.0/codegen/api_models_materialized.yaml
#	schema/core/v1.1.0/codegen/metadata_materialized.yaml
#	schema/core/v1.1.0/codegen/metadata_models.py
#	schema/core/v1.1.0/common.yaml
#	schema/core/v1.1.0/metadata.yaml
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models.py
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models.schema.json
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models_materialized.yaml
#	schema/ingestion_config/v1.0.0/ingestion_config_models.yaml
schema/api/v1.0.0/codegen/ER_DIAGRAM.md Outdated Show resolved Hide resolved
is_a: AnnotationSourceFile
aliases:
- TriangularMeshGroup
description: File and sourcing data for a triangular mesh annotation. Annotation that identifies an object.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this description be adapted for a mesh group?

mesh.apply_scale(scale_factor)
mesh.export(output_file)

return wrapper


def check_mesh_name(input_file: str, name: str) -> str:
with h5py.File(input_file, "r") as fp:
for mesh_list in fp["segment_list/"].keys(): # noqa
Copy link
Contributor

Choose a reason for hiding this comment

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

sanity check: Could there be a case, where this doesn't have segment_list/?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There shouldn't be but it's a possibility. I'll handle that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this does happen a key error will be thrown which names the missing key name. How does that sounds?

ingestion_tools/scripts/common/mesh_converter.py Outdated Show resolved Hide resolved
ingestion_tools/scripts/common/mesh_converter.py Outdated Show resolved Hide resolved
import trimesh


def generate_hff_mesh(input_file: str, output_file: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

Comment on lines +47 to +60
if __name__ == "__main__":
import os

# get test data location
cd = os.path.dirname(__file__).split("/")[0:-1]
test_data_location = os.path.join("/", *cd, "fixtures/annotations")

# create the input and output file paths
file_prefix = os.path.join(test_data_location, "triangular_mesh")
input_file = f"{file_prefix}.glb"
output_file = f"{file_prefix}.hff"

# generate the hff mesh file
generate_hff_mesh(input_file, output_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we want to retain this?

Copy link
Contributor Author

@Bento007 Bento007 Aug 31, 2024

Choose a reason for hiding this comment

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

If you're talking about the script, yes I think we should retain it. It could be helpful in the future for generating new hff files and fordebugging issues with hff conversion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker: I on the same page with having the generate_hff_mesh method. I was just curious about the code block inside the if __name__ == "__main__".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll keep it since it's a simple runnable example on how to generate the hff

Bento007 and others added 4 commits September 3, 2024 17:06
# Conflicts:
#	ingestion_tools/poetry.lock
#	schema/core/v1.1.0/codegen/metadata_materialized.yaml
#	schema/core/v1.1.0/codegen/metadata_models.py
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models.py
#	schema/ingestion_config/v1.0.0/codegen/ingestion_config_models_materialized.yaml
Copy link
Contributor

@manasaV3 manasaV3 left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -24,6 +24,7 @@ repos:
- apiv2/pyproject.toml
files: '^apiv2/.*'
- repo: https://github.com/mpalmer/action-validator
# requires installing `npm install -g @action-validator/core @action-validator/cli --save-dev`
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥

@Bento007 Bento007 merged commit f075561 into main Sep 4, 2024
6 checks passed
@Bento007 Bento007 deleted the tsmith/951-ingest-mesh-hff branch September 4, 2024 23:52
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.

2 participants