Update app.py
Browse files
app.py
CHANGED
@@ -24,19 +24,25 @@ def load_css():
|
|
24 |
</style>""",
|
25 |
unsafe_allow_html=True,
|
26 |
)
|
27 |
-
|
|
|
28 |
def load_all_models():
|
29 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
|
|
|
|
30 |
|
|
|
31 |
model_id = "ai4bharat/indictrans2-indic-en-dist-200M"
|
32 |
-
|
33 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
34 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, trust_remote_code=True)
|
35 |
|
|
|
36 |
text_gen = pipeline("text-generation", model="gpt2")
|
|
|
|
|
37 |
img_pipe = StableDiffusionPipeline.from_pretrained(
|
38 |
-
"CompVis/stable-diffusion-v1-4",
|
39 |
-
revision="fp16",
|
40 |
torch_dtype=torch.float16
|
41 |
).to("cuda")
|
42 |
|
|
|
24 |
</style>""",
|
25 |
unsafe_allow_html=True,
|
26 |
)
|
27 |
+
|
28 |
+
@st.cache_resource
|
29 |
def load_all_models():
|
30 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
31 |
+
from diffusers import StableDiffusionPipeline
|
32 |
+
import torch
|
33 |
|
34 |
+
# Translation model
|
35 |
model_id = "ai4bharat/indictrans2-indic-en-dist-200M"
|
|
|
36 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
37 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id, trust_remote_code=True)
|
38 |
|
39 |
+
# Text generation model (simple GPT-2)
|
40 |
text_gen = pipeline("text-generation", model="gpt2")
|
41 |
+
|
42 |
+
# Image generation model (Stable Diffusion)
|
43 |
img_pipe = StableDiffusionPipeline.from_pretrained(
|
44 |
+
"CompVis/stable-diffusion-v1-4",
|
45 |
+
revision="fp16",
|
46 |
torch_dtype=torch.float16
|
47 |
).to("cuda")
|
48 |
|