Spaces:
Runtime error
Runtime error
ShreyMehra
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ class UI:
|
|
49 |
else:
|
50 |
st.write("Upload an Image")
|
51 |
|
52 |
-
st.caption("
|
53 |
|
54 |
|
55 |
class Model:
|
@@ -58,20 +58,10 @@ class Model:
|
|
58 |
config = PeftConfig.from_pretrained(peft_model_id)
|
59 |
global model
|
60 |
global processor
|
61 |
-
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, low_cpu_mem_usage=True, torch_dtype=torch.
|
62 |
-
model.params = model.to_fp32(model.params)
|
63 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
64 |
processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
65 |
|
66 |
-
def query(self , payload):
|
67 |
-
response = requests.post(self.API_URL, headers=self.headers, json=payload)
|
68 |
-
return response.content
|
69 |
-
|
70 |
-
def generate_response(self, prompt):
|
71 |
-
image_bytes = self.query({ "inputs": prompt, })
|
72 |
-
return io.BytesIO(image_bytes)
|
73 |
-
|
74 |
-
|
75 |
def main():
|
76 |
ui = UI()
|
77 |
ui.displayUI()
|
|
|
49 |
else:
|
50 |
st.write("Upload an Image")
|
51 |
|
52 |
+
st.caption("NN Practical Project.")
|
53 |
|
54 |
|
55 |
class Model:
|
|
|
58 |
config = PeftConfig.from_pretrained(peft_model_id)
|
59 |
global model
|
60 |
global processor
|
61 |
+
model = Blip2ForConditionalGeneration.from_pretrained(config.base_model_name_or_path, low_cpu_mem_usage=True, torch_dtype=torch.float32) #, device_map="auto", load_in_8bit=True
|
|
|
62 |
model = PeftModel.from_pretrained(model, peft_model_id)
|
63 |
processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
def main():
|
66 |
ui = UI()
|
67 |
ui.displayUI()
|