Update app.py
Browse files
app.py
CHANGED
@@ -43,67 +43,3 @@ interface = gr.Interface(
|
|
43 |
article="<h1>Created By:</h1>Mr. Karma Wangchuk<br>Lecturer<br>Information Technology Department<br>College of Science and Technology<br>Rinchending Phuentsholing<br>Chhukha Bhutan<br>",
|
44 |
)
|
45 |
interface.launch(debug=True)
|
46 |
-
# import torch
|
47 |
-
# import re
|
48 |
-
# import gradio as gr
|
49 |
-
# from transformers import AutoTokenizer, ViTFeatureExtractor, VisionEncoderDecoderModel, AutoModelForSeq2SeqLM, pipeline
|
50 |
-
# from transformers import ViTImageProcessor
|
51 |
-
|
52 |
-
# device='cpu'
|
53 |
-
# encoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
54 |
-
# decoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
55 |
-
# model_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
56 |
-
|
57 |
-
# # feature_extractor = ViTFeatureExtractor.from_pretrained(encoder_checkpoint)
|
58 |
-
|
59 |
-
# feature_extractor = ViTImageProcessor.from_pretrained(encoder_checkpoint)
|
60 |
-
# tokenizer = AutoTokenizer.from_pretrained(decoder_checkpoint)
|
61 |
-
# model = VisionEncoderDecoderModel.from_pretrained(model_checkpoint).to(device)
|
62 |
-
|
63 |
-
# mod = AutoModelForSeq2SeqLM.from_pretrained("KarmaCST/nllb-200-distilled-600M-en-to-dz")
|
64 |
-
# tok = AutoTokenizer.from_pretrained("KarmaCST/nllb-200-distilled-600M-en-to-dz")
|
65 |
-
|
66 |
-
|
67 |
-
# src_lang = 'eng_Latn'
|
68 |
-
# tgt_lang = "dzo_Tibt"
|
69 |
-
|
70 |
-
|
71 |
-
# def predict(image,max_length=64, num_beams=4):
|
72 |
-
# image = image.convert('RGB')
|
73 |
-
# image = feature_extractor(image, return_tensors="pt").pixel_values.to(device)
|
74 |
-
# clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
|
75 |
-
# # caption_ids = model.generate(image, max_length = max_length)[0]
|
76 |
-
# caption_ids = model.generate(image, max_length = max_length, clean_up_tokenization_spaces=False)[0]
|
77 |
-
# caption_text = clean_text(tokenizer.decode(caption_ids))
|
78 |
-
|
79 |
-
# translation_pipeline = pipeline("translation",
|
80 |
-
# model=mod,
|
81 |
-
# tokenizer=tok,
|
82 |
-
# src_lang=src_lang,
|
83 |
-
# tgt_lang=tgt_lang)
|
84 |
-
|
85 |
-
# result = translation_pipeline(caption_text)
|
86 |
-
# return result[0]['translation_text']
|
87 |
-
|
88 |
-
|
89 |
-
# # input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
|
90 |
-
# # output = gr.outputs.Textbox(type="auto",label="Captions")
|
91 |
-
|
92 |
-
# # input = gr.Image(label="Upload any Image", type = 'pil', optional=True)
|
93 |
-
# input = gr.Image(label="Upload any Image", type = 'pil')
|
94 |
-
# output = gr.Textbox(type="auto",label="Captions")
|
95 |
-
|
96 |
-
# examples = [f"example{i}.jpg" for i in range(1,7)]
|
97 |
-
|
98 |
-
# title = "Image Captioning in Dzongkha "
|
99 |
-
|
100 |
-
# interface = gr.Interface(
|
101 |
-
# fn=predict,
|
102 |
-
# inputs = input,
|
103 |
-
# theme="grass",
|
104 |
-
# outputs=output,
|
105 |
-
# examples = examples,
|
106 |
-
# title=title,
|
107 |
-
# article="<h1>Created By:</h1>Mr. Karma Wangchuk<br>Lecturer<br>Information Technology Department<br>College of Science and Technology<br>Rinchending Phuentsholing<br>Chhukha Bhutan<br>",
|
108 |
-
# )
|
109 |
-
# interface.launch(debug=True)
|
|
|
43 |
article="<h1>Created By:</h1>Mr. Karma Wangchuk<br>Lecturer<br>Information Technology Department<br>College of Science and Technology<br>Rinchending Phuentsholing<br>Chhukha Bhutan<br>",
|
44 |
)
|
45 |
interface.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|