thak123 commited on
Commit
79c3b28
1 Parent(s): bd56983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -18
app.py CHANGED
@@ -3,7 +3,6 @@ import os
3
  os.environ["WANDB_DISABLED"] = "true"
4
 
5
  import numpy as np
6
- from PIL import Image
7
 
8
  import gradio as gr
9
  import torch
@@ -116,25 +115,14 @@ config = model.vision_encoder.config
116
  sf_filename = hf_hub_download("FFZG-cleopatra/M2SA", filename="model.safetensors")
117
 
118
  load_model(model, sf_filename)
119
- # model.load_state_dict(torch.load(model_args.model_name_or_path+"-finetuned/pytorch_model.bin"))
120
-
121
-
122
- # model = AutoModelForSequenceClassification.from_pretrained(
123
- # "FFZG-cleopatra/M2SA",
124
- # num_labels=3, id2label=id2label,
125
- # label2id=label2id
126
- # )
127
-
128
-
129
-
130
  image_processor = AutoImageProcessor.from_pretrained("openai/clip-vit-base-patch32")
131
 
132
  def predict_sentiment(text, image):
133
  print(text, image)
134
- print(dir(image))
135
  image = read_image(image, mode=ImageReadMode.RGB)
136
- # image = transforms.ToTensor()(image).unsqueeze(0)
137
- print(image)
138
  text_inputs = tokenizer(
139
  text,
140
  max_length=512,
@@ -152,9 +140,6 @@ def predict_sentiment(text, image):
152
  pixel_values = image_transformations(image)
153
  text_inputs["pixel_values"] = pixel_values.unsqueeze(0)
154
 
155
- print(text_inputs)
156
- print("its going in ",pixel_values)
157
-
158
  prediction = None
159
  with torch.no_grad():
160
  outputs = model(**text_inputs)
 
3
  os.environ["WANDB_DISABLED"] = "true"
4
 
5
  import numpy as np
 
6
 
7
  import gradio as gr
8
  import torch
 
115
  sf_filename = hf_hub_download("FFZG-cleopatra/M2SA", filename="model.safetensors")
116
 
117
  load_model(model, sf_filename)
 
 
 
 
 
 
 
 
 
 
 
118
  image_processor = AutoImageProcessor.from_pretrained("openai/clip-vit-base-patch32")
119
 
120
  def predict_sentiment(text, image):
121
  print(text, image)
122
+
123
  image = read_image(image, mode=ImageReadMode.RGB)
124
+
125
+
126
  text_inputs = tokenizer(
127
  text,
128
  max_length=512,
 
140
  pixel_values = image_transformations(image)
141
  text_inputs["pixel_values"] = pixel_values.unsqueeze(0)
142
 
 
 
 
143
  prediction = None
144
  with torch.no_grad():
145
  outputs = model(**text_inputs)