talantbekdeveloper commited on
Commit
96ffe4e
·
verified ·
1 Parent(s): ff7da7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,9 +1,15 @@
1
- from transformers import pipeline
2
- import gradio as gr
 
 
 
 
 
 
3
 
4
- pipe = pipeline("image-classification", model="google/vit-base-patch16-224")
5
-
6
- gr.Interface.from_pipeline(pipe).launch()
7
 
8
  # import streamlit as st
9
  # from transformers import pipeline
 
1
+ from transformers import AutoImageProcessor, AutoBackbone
2
+ import torch
3
+ from PIL import Image
4
+ import requests
5
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
6
+ image = Image.open(requests.get(url, stream=True).raw)
7
+ processor = AutoImageProcessor.from_pretrained("microsoft/swin-tiny-patch4-window7-224")
8
+ model = AutoBackbone.from_pretrained("microsoft/swin-tiny-patch4-window7-224", out_indices=(1,))
9
 
10
+ inputs = processor(image, return_tensors="pt")
11
+ outputs = model(**inputs)
12
+ feature_maps = outputs.feature_maps
13
 
14
  # import streamlit as st
15
  # from transformers import pipeline