diff --git a/.idea/ai_debugger.xml b/.idea/ai_debugger.xml new file mode 100644 index 0000000..b405196 --- /dev/null +++ b/.idea/ai_debugger.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/server.py b/server.py index ab20580..0e43be1 100755 --- a/server.py +++ b/server.py @@ -17,7 +17,7 @@ from minio import Minio from glb2svg import glb_to_obj, obj_to_step, step_to_svg from trellis.pipelines import TrellisImageTo3DPipeline from trellis.utils import render_utils, postprocessing_utils -from utils.new_oss_client import MINIO_URL, MINIO_ACCESS, MINIO_SECRET, MINIO_SECURE, minio_get_image, MINIO_BUCKET, upload_bytes, upload_local_file, download_from_minio +from utils.new_oss_client import MINIO_URL, MINIO_ACCESS, MINIO_SECRET, MINIO_SECURE, minio_get_image, upload_local_file, download_from_minio minio_client = Minio(MINIO_URL, access_key=MINIO_ACCESS, secret_key=MINIO_SECRET, secure=MINIO_SECURE) @@ -347,11 +347,12 @@ class ModelToThreeViews(ls.LitAPI): def setup(self, device): pass - def upload_local_file(self, local_path, type): + def upload_local_file(self, local_path, type, bucket_name, user_id): """ 通用上传函数:支持 SVG, PNG, OBJ 等 """ - object_name = f"3d_result/{type}/{uuid.uuid4().hex}.{type}" + + object_name = f"{user_id}/3d_result/{type}/{uuid.uuid4().hex}.{type}" if not os.path.exists(local_path): print(f"错误: 文件 {local_path} 不存在") return None @@ -364,19 +365,21 @@ class ModelToThreeViews(ls.LitAPI): try: minio_client.fput_object( - bucket_name=MINIO_BUCKET, + bucket_name=bucket_name, object_name=object_name, file_path=local_path, content_type=content_type ) print(f"成功上传 [{content_type}]: {object_name}") - return f"{MINIO_BUCKET}/{object_name}" + return f"{bucket_name}/{object_name}" except Exception as e: print(f"上传失败: {e}") return None def predict(self, request): minio_glb_path = request['minio_glb_path'] + bucket_name = request["bucket_name"] + user_id = request["user_id"] work_dir = f"glb_to_obj" os.makedirs(work_dir, exist_ok=True) @@ -425,7 +428,7 @@ class ModelToThreeViews(ls.LitAPI): print("=" * 10) # 5 上传 - minio_svg_path = self.upload_local_file(combined_png, "svg") + minio_svg_path = self.upload_local_file(combined_png, "svg", bucket_name, user_id) return {"minio_svg_path": minio_svg_path} @@ -436,4 +439,4 @@ if __name__ == "__main__": server = ls.LitServer([ trellis_api, model_to_three_api]) - server.run(port=8120) + server.run(port=8122)