Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
cfb0d00
1
Parent(s):
fbbbcab
fix
Browse files
utils/__pycache__/interface.cpython-310.pyc
CHANGED
|
Binary files a/utils/__pycache__/interface.cpython-310.pyc and b/utils/__pycache__/interface.cpython-310.pyc differ
|
|
|
utils/interface.py
CHANGED
|
@@ -36,7 +36,6 @@ class Inference:
|
|
| 36 |
model_path, trust_remote_code=True, device_map="auto"
|
| 37 |
).eval()
|
| 38 |
|
| 39 |
-
@spaces.GPU(duration = 120)
|
| 40 |
def forward(
|
| 41 |
self,
|
| 42 |
task: str,
|
|
@@ -55,7 +54,6 @@ class Inference:
|
|
| 55 |
if system_prompt:
|
| 56 |
full_conversation.append({"role": "system", "content": system_prompt})
|
| 57 |
|
| 58 |
-
|
| 59 |
# Add previous turns from the formatted history
|
| 60 |
full_conversation.extend(conversation_history_for_model)
|
| 61 |
|
|
@@ -90,18 +88,23 @@ class Inference:
|
|
| 90 |
}
|
| 91 |
generation_config = GenerationConfig(**generate_kwargs)
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
# As per requirement, always one output modality, so take the first result
|
| 107 |
response_obj = results[0]
|
|
|
|
| 36 |
model_path, trust_remote_code=True, device_map="auto"
|
| 37 |
).eval()
|
| 38 |
|
|
|
|
| 39 |
def forward(
|
| 40 |
self,
|
| 41 |
task: str,
|
|
|
|
| 54 |
if system_prompt:
|
| 55 |
full_conversation.append({"role": "system", "content": system_prompt})
|
| 56 |
|
|
|
|
| 57 |
# Add previous turns from the formatted history
|
| 58 |
full_conversation.extend(conversation_history_for_model)
|
| 59 |
|
|
|
|
| 88 |
}
|
| 89 |
generation_config = GenerationConfig(**generate_kwargs)
|
| 90 |
|
| 91 |
+
@spaces.GPU(duration = 120)
|
| 92 |
+
def gen_spaces():
|
| 93 |
+
token_ids = self.model.generate(
|
| 94 |
+
input_ids=inputs["input_ids"].to(self.device),
|
| 95 |
+
attention_mask=inputs["attention_mask"].to(self.device),
|
| 96 |
+
generation_config=generation_config,
|
| 97 |
+
stopping_criteria=stopping_criteria
|
| 98 |
+
)
|
| 99 |
|
| 100 |
+
results = self.processor.decode(
|
| 101 |
+
token_ids.to(self.device),
|
| 102 |
+
output_modalities,
|
| 103 |
+
decoder_audio_prompt_path=decoder_audio_prompt_path
|
| 104 |
+
)
|
| 105 |
+
return results
|
| 106 |
+
|
| 107 |
+
results = gen_spaces()
|
| 108 |
|
| 109 |
# As per requirement, always one output modality, so take the first result
|
| 110 |
response_obj = results[0]
|