CollinMa's picture
Publish NExT-GPT course code and actual execution records
15c46ce verified
Raw History Blame Contribute Delete
1.35 kB
"""Import the complete inference graph and build the UI without model weights."""
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from settings import CODE
sys.path.insert(0, str(CODE))
if __name__ == "__main__":
import torch
import torchaudio
import transformers
import diffusers
from model.anyToImageVideoAudio import NextGPTModel
from model.ImageBind.data import BPE_PATH
from model.ImageBind.models.multimodal_preprocessors import SimpleTokenizer
if not torchaudio.list_audio_backends():
raise RuntimeError("No audio decoding backend: install soundfile.")
tokenizer = SimpleTokenizer(bpe_path=BPE_PATH)
tokens = tokenizer("A short multimodal test")
if tokens.numel() == 0:
raise RuntimeError("ImageBind tokenizer produced no tokens.")
import app
if not app.demo.config.get("components"):
raise RuntimeError("Gradio UI has no components.")
print(json.dumps({"import_smoke": "passed", "torch": torch.__version__,
"transformers": transformers.__version__, "diffusers": diffusers.__version__,
"cuda_available": torch.cuda.is_available(), "model_weights_loaded": False,
"ui_components": len(app.demo.config["components"])}))