Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,22 +2,33 @@ import gradio as gr
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
import torch.amp as amp
|
| 5 |
-
from transformers import pipeline
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
@spaces.GPU
|
| 11 |
def upsample(prompt):
|
| 12 |
-
|
| 13 |
-
[{"role": "user", "content": f"Upsample the short caption to a long caption: {prompt}"}],
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
demo = gr.Interface(
|
| 19 |
title="NVIDIA Cosmos π Prompt Upsampler",
|
| 20 |
-
description="""Upsample prompts using NVIDIA's 12B Cosmos model, based on Mistral NeMo 12B. This space uses
|
| 21 |
|
| 22 |
[[cosmos]](https://huggingface.co/nvidia/Cosmos-1.0-Prompt-Upsampler-12B-Text2World) [[transformers]](https://huggingface.co/appmana/Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf) [[gguf]](https://huggingface.co/mradermacher/Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf-GGUF)""",
|
| 23 |
fn=upsample,
|
|
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
import torch.amp as amp
|
|
|
|
| 5 |
|
| 6 |
+
from huggingface_hub import hf_hub_download
|
| 7 |
+
from llama_cpp import Llama
|
| 8 |
+
|
| 9 |
+
model = hf_hub_download(
|
| 10 |
+
"mradermacher/Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf-GGUF",
|
| 11 |
+
filename="Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf.Q8_0.gguf",
|
| 12 |
+
)
|
| 13 |
+
llama = Llama(
|
| 14 |
+
model,
|
| 15 |
+
n_gpu_layers=-1,
|
| 16 |
+
n_ctx=2048,
|
| 17 |
+
verbose=False
|
| 18 |
+
)
|
| 19 |
|
| 20 |
@spaces.GPU
|
| 21 |
def upsample(prompt):
|
| 22 |
+
completion = llama.create_chat_completion(
|
| 23 |
+
messages=[{"role": "user", "content": f"Upsample the short caption to a long caption: {prompt}"}],
|
| 24 |
+
max_tokens=512,
|
| 25 |
+
)
|
| 26 |
+
response = completion["choices"][0]["message"]["content"]
|
| 27 |
+
return response
|
| 28 |
|
| 29 |
demo = gr.Interface(
|
| 30 |
title="NVIDIA Cosmos π Prompt Upsampler",
|
| 31 |
+
description="""Upsample prompts using NVIDIA's 12B Cosmos model, based on Mistral NeMo 12B. This space uses llama.cpp with the Q8-0 quantized GGUF checkpoint.
|
| 32 |
|
| 33 |
[[cosmos]](https://huggingface.co/nvidia/Cosmos-1.0-Prompt-Upsampler-12B-Text2World) [[transformers]](https://huggingface.co/appmana/Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf) [[gguf]](https://huggingface.co/mradermacher/Cosmos-1.0-Prompt-Upsampler-12B-Text2World-hf-GGUF)""",
|
| 34 |
fn=upsample,
|