venkat charan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,15 @@
|
|
1 |
-
|
|
|
2 |
import torch
|
3 |
-
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=False, use_safetensors=True
|
12 |
-
)
|
13 |
-
model.to(device)
|
14 |
-
|
15 |
-
processor = AutoProcessor.from_pretrained(model_id)
|
16 |
-
|
17 |
-
pipe = pipeline(
|
18 |
-
"automatic-speech-recognition",
|
19 |
-
model=model,
|
20 |
-
tokenizer=processor.tokenizer,
|
21 |
-
feature_extractor=processor.feature_extractor,
|
22 |
-
max_new_tokens=128,
|
23 |
-
chunk_length_s=30,
|
24 |
-
batch_size=16,
|
25 |
-
return_timestamps=True,
|
26 |
-
torch_dtype=torch_dtype,
|
27 |
-
device=device,
|
28 |
-
)
|
29 |
-
result = pipe("/content/BryanThe_Ideal_Republic.ogg", generate_kwargs={"language": "french"})
|
30 |
-
print(result["text"]) # transcritpion
|
31 |
-
print(result["chunks"]) # translation
|
32 |
-
|
33 |
-
from transformers import RagTokenizer, RagRetriever, RagSequenceForGeneration
|
34 |
-
|
35 |
-
|
36 |
-
tokenizer = RagTokenizer.from_pretrained("facebook/rag-token-nq")
|
37 |
-
retriever = RagRetriever.from_pretrained("facebook/rag-token-nq", index_name="exact", use_dummy_dataset=True)
|
38 |
-
rag_model = RagSequenceForGeneration.from_pretrained("facebook/rag-token-nq", retriever=retriever)
|
39 |
-
|
40 |
-
def retrieve_and_generate_response(transcribed_text):
|
41 |
-
# Tokenize the transcribed text
|
42 |
-
input_ids = tokenizer(transcribed_text, return_tensors="pt").input_ids
|
43 |
-
|
44 |
-
# Generate response
|
45 |
-
outputs = rag_model.generate(input_ids)
|
46 |
-
response = tokenizer.batch_decode(outputs, skip_special_tokens=True)[0]
|
47 |
-
|
48 |
-
return response
|
49 |
-
|
50 |
-
response = retrieve_and_generate_response(result["text"])
|
51 |
-
print("Response:", response)
|
52 |
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import numpy
|
3 |
import torch
|
4 |
+
import matplotlib.pyplot
|
5 |
+
import PIL
|
6 |
+
from PIL import Image
|
7 |
+
import streamlit as st
|
8 |
|
9 |
+
st.write('age detection')
|
10 |
+
upload_file = st.file_uploader('choose a image file',type='jpg')
|
11 |
|
12 |
+
pipe = pipeline("image-classifcation",model='dima806/facial_age_image_detection')
|
13 |
|
14 |
+
st.write(pipe(st.imagw(Image.open(upload_file)))[0]['label'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|