Skip to content
Snippets Groups Projects
Commit 667a6e17 authored by BIRK Renaud's avatar BIRK Renaud
Browse files

feat: API GET /glb - adding raw file

parent b2f7c4e0
No related branches found
No related tags found
No related merge requests found
import base64
import os
from gradio_client import Client, handle_file
from flask import jsonify, Response
......@@ -27,7 +28,7 @@ class GlbController:
api_name="/get_seed"
)
client.predict(
image_to_3d = client.predict(
image=handle_file(preprocess_image_result),
multiimages=[],
seed=get_seed_result,
......@@ -45,4 +46,17 @@ class GlbController:
api_name="/extract_glb"
)
return jsonify({"path": extract_glb})
extracted_glb_path = extract_glb[0]
preview_path = image_to_3d["video"]
glb = ''
with open(extracted_glb_path, "rb") as glb_file:
encoded_string = base64.b64encode(glb_file.read()).decode('utf-8')
glb = encoded_string
preview = ''
with open(preview_path, "rb") as preview_file:
encoded_string = base64.b64encode(preview_file.read()).decode('utf-8')
preview = encoded_string
return jsonify({"glb": glb, "glb_path": extracted_glb_path, "preview": preview, "preview_path": preview_path})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment