# image-from-xsem-and-random-xt
This document explains how to generate an image-from-xsem-and-random-xt.
## image-from-xsem-and-random-xt
```python
from PIL import Image
import torch
import torchvision.transforms as transforms
from torchvision.transforms import functional as VF
from templates import ffhq256_autoenc, LitModel
device = 'cuda'
conf = ffhq256_autoenc()
model = LitModel(conf)
# Load and preprocess an image
img = Image.open('example.jpg').resize((256, 256)).convert('RGB')
x = VF.to_tensor(img).unsqueeze(0).to(device)
to_tensor = transforms.ToTensor()
xsem = model.encode(x)
xt = model.encode_stochastic(x, cond, T=250)
# Generate random xt
random_x_t = torch.randn_like(model.encode_t(x, t=50))
# Decode image using x_sem and random_x_t
random_xt_image = model.decode(xsem, random_x_t)
## Expected Output
- Demonstrates the effect of randomness in image synthesis.