Comments (3)
Thanks a lot for your attention!
Here is the pseudo-code for generating an RGB heatmap using the predicted reconstruction loss:
def show_loss_pred(model, inputs, img, num_patches=196, h=14, w=14, input_size=224):
# generate a full visible mask
mask = np.zeros((num_patches)).astype(bool)
mask = torch.from_numpy(mask).unsqueeze(0).bool()
with torch.no_grad():
outs = model(inputs, mask)
loss_show = outs['loss_pred'][0].cpu()
# postprocessing for predicted loss
loss_show = loss_show - loss_show.mean()
loss_show = np.exp(loss_show) / (1 + np.exp(loss_show))
loss_show = loss_show / loss_show.max()
loss_show = (loss_show * 255).numpy().astype(np.uint8)
reconstruct = loss_show.copy()
reconstruct = reconstruct.reshape((h, w)).astype(np.uint8)
reconstruct_color = cv2.applyColorMap(reconstruct, cv2.COLORMAP_JET)
reconstruct_color = np.array(cv2.cvtColor(reconstruct_color, cv2.COLOR_BGR2RGB))
rec_big = np.zeros((input_size, input_size, 3)).astype(np.uint8)
for i in range(h):
for j in range(w):
rec_big[i * 16: i * 16 + 16, j * 16: j * 16 + 16, :] = reconstruct_color[i, j]
img = np.array(img)
img_show = (0.5 * img + 0.5 * rec_big).astype(np.uint8)
return img_show
from hpm.
Thank you very much, itβs work!
from hpm.
Happy to hear that :)
I hope our work brings inspiration to you.
from hpm.
Related Issues (8)
- input mismatch of loss predictor HOT 3
- question about COCO detection HOT 13
- Confused about "model_teacher" in pre-training code HOT 2
- Request for certain experimental matters HOT 2
- Questions Regarding Pretraining Experiment Configuration HOT 1
- Question about pretrain models on 800 epochs HOT 2
- Availability of Pre-trained Models
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hpm.