Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,17 +63,18 @@ def generate_image(prompt):
|
|
63 |
print(f"An error occurred: {e}")
|
64 |
return None
|
65 |
|
66 |
-
#
|
67 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
68 |
|
69 |
-
|
70 |
-
|
|
|
71 |
|
72 |
-
# Function to generate creative text based on translated text
|
73 |
def generate_creative_text(translated_text):
|
74 |
-
input_ids =
|
75 |
-
generated_text_ids =
|
76 |
-
creative_text =
|
77 |
return creative_text
|
78 |
|
79 |
# Function to handle the full workflow
|
|
|
63 |
print(f"An error occurred: {e}")
|
64 |
return None
|
65 |
|
66 |
+
# Import necessary libraries for Mistral model
|
67 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
68 |
|
69 |
+
# Load Mistral model and tokenizer
|
70 |
+
mistral_tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
|
71 |
+
mistral_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
|
72 |
|
73 |
+
# Function to generate creative text based on translated text using Mistral
|
74 |
def generate_creative_text(translated_text):
|
75 |
+
input_ids = mistral_tokenizer(translated_text, return_tensors='pt').input_ids
|
76 |
+
generated_text_ids = mistral_model.generate(input_ids, max_length=100)
|
77 |
+
creative_text = mistral_tokenizer.decode(generated_text_ids[0], skip_special_tokens=True)
|
78 |
return creative_text
|
79 |
|
80 |
# Function to handle the full workflow
|