Spaces:
Running
Running
| print(' # ************************Begin***********************************') | |
| import gradio as gr | |
| from huggingface_hub import InferenceClient | |
| # Check for T4 GPU | |
| import torch | |
| import os | |
| print('load libs') | |
| if torch.cuda.is_available(): | |
| #and "T4" in torch.cuda.get_device_name(0): | |
| print("β GPU detected") | |
| else: | |
| print(""" | |
| β οΈ WARNING: T4 GPU not detected | |
| The recommended runtime for this Colab notebook is "T4 GPU". | |
| To change the runtime type: | |
| 1. Click on "Runtime" in the top navigation menu | |
| 2. Click on "Change runtime type" | |
| 3. Select "T4 GPU" | |
| 4. Click "OK" if a "Disconnect and delete runtime" window appears | |
| 5. Click on "Save" | |
| """) | |
| # Clone the VibeVoice repository | |
| # ![ -d /VibeVoice ] || git clone --quiet --branch main --depth 1 https://github.com/microsoft/VibeVoice.git /VibeVoice | |
| os.system(" [ -d /tmp/VibeVoice ] || git clone --branch main https://huggingface.co/vibevoice/VibeVoice-7B /tmp/VibeVoice") | |
| print("β Cloned VibeVoice repository") | |
| # Install project dependencies | |
| os.system("uv pip --quiet install --system -e /tmp/VibeVoice") | |
| print("β Installed dependencies") | |
| # Download model (~3 minutes) | |
| # !HF_XET_HIGH_PERFORMANCE=1 hf download microsoft/VibeVoice-1.5B --quiet --local-dir /content/models/VibeVoice-1.5B > /dev/null | |
| # print("β Downloaded model: microsoft/VibeVoice-1.5B") | |
| def be_happy(happy): | |
| if happy: | |
| print('I"am happy') | |
| return happy | |
| if __name__ == "__main__": | |
| print('don"t warry') | |
| be_happy(True) | |
| LOADED_MODEL = "vibevoice/VibeVoice-7B" # just to break "if LOADED_MODEL is not None:" | |
| if LOADED_MODEL is not None: | |
| # Ganti 'interface' menjadi 'app' | |
| app = gr.Interface( | |
| fn='', | |
| inputs=gr.Image(type="numpy", label="Unggah Gambar Model Rambut"), | |
| outputs=gr.Markdown(label="Hasil Prediksi dan Rekomendasi"), | |
| title="Klasifikasi Tipe Rambut dan Rekomendasi Perawatan", | |
| description="Unggah gambar model rambut untuk mendapatkan prediksi tipe rambut (Curly, Dreadlocks, Kinky, Straight, Wavy) dan rekomendasi perawatan.", | |
| examples=[ # Opsional: Tambahkan contoh gambar untuk dicoba | |
| # Contoh gambar ini perlu ada di folder 'examples' di Spaces Anda | |
| # atau ganti dengan URL gambar publik jika ingin langsung dari internet | |
| # "./examples/curly_example.jpg", | |
| # "./examples/straight_example.jpg" | |
| ] | |
| ) | |
| # Tambahkan baris ini untuk mengaktifkan antrean Gradio | |
| #app.queue() # .launch() is missing! | |
| app.queue().launch() # <= Added | |