import open3d as o3d import streamlit as st # Streamlit title and description st.title("Jewelry 3D Model Viewer") st.write("Upload an OBJ file to visualize the 3D model of jewelry.") # File uploader for the OBJ file uploaded_file = st.file_uploader("Choose an OBJ file", type="obj") if uploaded_file is not None: # Save the uploaded file to a temporary location with open("uploaded_model.obj", "wb") as f: f.write(uploaded_file.getbuffer()) # Load the mesh using Open3D mesh = o3d.io.read_triangle_mesh("uploaded_model.obj") mesh.compute_vertex_normals() # Convert the mesh to a visualizable format for Streamlit vertices = mesh.vertices triangles = mesh.triangles vertex_colors = mesh.vertex_colors st.write("### 3D Model Preview") st.write("Mesh Vertices: ", len(vertices)) st.write("Mesh Triangles: ", len(triangles)) # Display the 3D mesh using Streamlit's 3D visualization support st.write("You can download Open3D and use it to visualize the mesh locally.") # Optionally, display the mesh information st.write(mesh) else: st.write("Please upload an OBJ file to visualize the jewelry model.")