Skip to content

Instantly share code, notes, and snippets.

@jschoormans
jschoormans / gist:3a5013ebd358d9563a41eadfbe9dac2c
Last active February 17, 2023 10:33
Convert pyvista to trimesh mesh (python libraries)
box = pv.Box()
box.triangulate()
faces = box.faces.reshape((-1,5)) #first dim is nr of points
faces = faces[:,1:]
t = trimesh.creation.Trimesh(vertices=np.array(box.points),
faces = faces,
face_normals = t2.face_normals)
@jschoormans
jschoormans / equirectangular.py
Created December 8, 2022 23:08
generate 3D panorama views with stable diffusion
# %%
import replicate
model = replicate.models.get("prompthero/openjourney")
version = model.versions.get("9936c2001faa2194a261c01381f90e65261879985476014a0a37a334593a05eb")
PROMPT = "mdjrny-v4 style 360 degree equirectangular panorama photograph, Alps, giant mountains, meadows, rivers, rolling hills, trending on artstation, cinematic composition, beautiful lighting, hyper detailed, 8 k, photo, photography"
output = version.predict(prompt=PROMPT, width=1024, height=512)
# %%
# download the iamge from the url at output[0]
import requests
HEIGHT=768
WIDTH=1024
OVERLAP = 256
PROMPT = "360 degree equirectangular panorama photograph, alps, mountains, landscape,\
trending on artstation, cinematic composition, beautiful lighting, hyper detailed, 8 k, photo, photography"
INPAINT_FIRST = False # use inpainting to fill in the first frame (force blue, green etc)
USE_OPEN_JOURNEY = False # open journey is nice, but inpainting works with vanilla SD - sometimes the difference is too big.
#Also open journey does not work with all resolution sizes
# First image - no overlap here.
'''
Sends a slack message to #general if there are any lambdalabs instances available
If there are, it will also send a message to #general with the name and price of the instance
If there are GPU instances available, it will also request one
'''
from slack_utils import send_slack_message
import requests
@jschoormans
jschoormans / main.py
Created January 12, 2024 07:43
CLI image folder to densepose, instead of video. Replace main.py from the https://github.com/Flode-Labs/vid2densepose repo
import argparse
import os
import PIL
import cv2
import numpy as np
import torch
from densepose import add_densepose_config
from densepose.vis.densepose_results import (
DensePoseResultsFineSegmentationVisualizer as Visualizer,
)