Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,11 +6,8 @@ import spaces
|
|
6 |
import gc
|
7 |
import torch
|
8 |
|
9 |
-
from gradio_client import Client
|
10 |
-
import pyarabic.araby as araby
|
11 |
-
|
12 |
# Create the necessary directories
|
13 |
-
os.makedirs('.gradio/cached_examples/17', exist_ok=True)
|
14 |
|
15 |
|
16 |
def get_model_name(language):
|
@@ -45,7 +42,7 @@ def load_model(model_name):
|
|
45 |
|
46 |
return generator
|
47 |
|
48 |
-
|
49 |
@spaces.GPU
|
50 |
def generate_kids_story(character, setting, language):
|
51 |
model_name = get_model_name(language)
|
@@ -61,9 +58,6 @@ def generate_kids_story(character, setting, language):
|
|
61 |
|
62 |
messages = [{"role": "user", "content": prompt}]
|
63 |
output = generator(messages)
|
64 |
-
|
65 |
-
text = output[0]["generated_text"]
|
66 |
-
|
67 |
# Delete model and associated objects
|
68 |
del generator
|
69 |
# Run garbage collection
|
@@ -71,13 +65,8 @@ def generate_kids_story(character, setting, language):
|
|
71 |
# Empty CUDA cache
|
72 |
torch.cuda.empty_cache()
|
73 |
|
74 |
-
# Remove diacritics from Arabic text then add tashkeel
|
75 |
-
if language == "Arabic":
|
76 |
-
text = client.predict(
|
77 |
-
input_text=araby.strip_diacritics(text),
|
78 |
-
api_name="/infer_shakkala")
|
79 |
|
80 |
-
return
|
81 |
|
82 |
css_style = """
|
83 |
body {
|
|
|
6 |
import gc
|
7 |
import torch
|
8 |
|
|
|
|
|
|
|
9 |
# Create the necessary directories
|
10 |
+
# os.makedirs('.gradio/cached_examples/17', exist_ok=True)
|
11 |
|
12 |
|
13 |
def get_model_name(language):
|
|
|
42 |
|
43 |
return generator
|
44 |
|
45 |
+
|
46 |
@spaces.GPU
|
47 |
def generate_kids_story(character, setting, language):
|
48 |
model_name = get_model_name(language)
|
|
|
58 |
|
59 |
messages = [{"role": "user", "content": prompt}]
|
60 |
output = generator(messages)
|
|
|
|
|
|
|
61 |
# Delete model and associated objects
|
62 |
del generator
|
63 |
# Run garbage collection
|
|
|
65 |
# Empty CUDA cache
|
66 |
torch.cuda.empty_cache()
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
return output[0]["generated_text"]
|
70 |
|
71 |
css_style = """
|
72 |
body {
|