Spaces:
Sleeping
Sleeping
File size: 923 Bytes
4c11400 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import streamlit as st
import os
import nerf
import torch
# Check if the directory called Model exists
if not os.path.exists("Model"):
# Create the directory
os.mkdir("Model")
# Check if the model is downloaded
if not os.path.exists("Model/nerf_model.ckpt"):
# Download the model
wget https://github.com/bmild/nerf/releases/download/v0.5/nerf_model.ckpt
# Load the NeRF model
nerf_model = nerf.NeRF.load("Model/nerf_model.ckpt")
# Define the camera parameters
camera = nerf.Camera(
fov=60,
focal_length=50,
znear=1,
zfar=100,
principal_point=(0.5, 0.5),
)
# Define the viewing direction
viewing_direction = torch.tensor([0, 0, 1])
# Render the novel view
novel_view = nerf_model.render(viewing_direction, camera)
# Save the novel view
torch.save(novel_view, "novel_view.png")
# Create a Streamlit app
st.title("NeRF with Dolly Zoom")
# Show the image
st.image("novel_view.png")
|