ManishThota commited on
Commit
c52e238
1 Parent(s): 0c52e55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -6,6 +6,14 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
6
  #Setting device to cuda
7
  torch.set_default_device("cuda")
8
 
 
 
 
 
 
 
 
 
9
  # Initialize the model and tokenizer
10
  model = AutoModelForCausalLM.from_pretrained("ManishThota/Sparrow",
11
  torch_dtype=torch.float16,
@@ -39,7 +47,7 @@ iface = gr.Interface(
39
  fn=gradio_predict,
40
  inputs=[gr.Image(type="pil", label="Upload or Drag an Image"),
41
  gr.Textbox(label="Question", placeholder="e.g. What are the colors of the bus in the image?", scale=4),
42
- gr.Slider(2, 100, value=25, label="Count", info="Choose between 2 and 100")],
43
  outputs=gr.TextArea(label="Answer"),
44
  title="Sparrow - Tiny 3B | Visual Question Answering",
45
  description="An interactive chat model that can answer questions about images in an Academic context. \n We can input images, and the system will analyze them to provide information about their contents. I've utilized this capability by feeding slides from PowerPoint presentations used in classes and the lecture content passed as text. Consequently, the model now mimics the behavior and responses of my professors. So, if I present any PowerPoint slide, it explains it just like my professor would, further it can be personalized.",
 
6
  #Setting device to cuda
7
  torch.set_default_device("cuda")
8
 
9
+ # # Ensure GPU usage if available
10
+ # device = "cuda" if torch.cuda.is_available() else "cpu"
11
+ # torch.set_default_tensor_type('torch.cuda.FloatTensor' if device=='cuda' else 'torch.FloatTensor')
12
+
13
+ torch.set_default_tensor_type('torch.cuda.FloatTensor')
14
+
15
+
16
+
17
  # Initialize the model and tokenizer
18
  model = AutoModelForCausalLM.from_pretrained("ManishThota/Sparrow",
19
  torch_dtype=torch.float16,
 
47
  fn=gradio_predict,
48
  inputs=[gr.Image(type="pil", label="Upload or Drag an Image"),
49
  gr.Textbox(label="Question", placeholder="e.g. What are the colors of the bus in the image?", scale=4),
50
+ gr.Slider(2, 100, value=25, label="Token Count", info="Choose between 2 and 100")],
51
  outputs=gr.TextArea(label="Answer"),
52
  title="Sparrow - Tiny 3B | Visual Question Answering",
53
  description="An interactive chat model that can answer questions about images in an Academic context. \n We can input images, and the system will analyze them to provide information about their contents. I've utilized this capability by feeding slides from PowerPoint presentations used in classes and the lecture content passed as text. Consequently, the model now mimics the behavior and responses of my professors. So, if I present any PowerPoint slide, it explains it just like my professor would, further it can be personalized.",