-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
39 lines (24 loc) · 5.29 KB
/
main.py
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
import accelerate
import transformers
import preprocessing as pre
from config import CFG
import trainer as tr
import inference as inf
df = pre.read_data(CFG['data_path'])
df = pre.preprocess_data(df)
print(len(df))
print(df.head())
train_df,val_df,test_df = pre.train_validation_test_split(df,CFG['train_size'],CFG['val_size'],CFG['test_size']) # splitting data into train, validation and test set
hf_train_dataset,hf_val_dataset,hf_test_dataset = pre.pandas_to_dataset(train_df,val_df,test_df)
tokenized_train_dataset,tokenized_val_dataset,tokenized_test_dataset = pre.tokenize_hf_dataset(hf_train_dataset,hf_val_dataset,hf_test_dataset)
trainer = tr.training_function(tokenized_train_dataset,tokenized_val_dataset)
trainer.save_model("./finetuned-flanT5_final/")
trainer.save_state()
trainer.evaluate(eval_dataset=tokenized_test_dataset)
# inference
model,tokenizer = inf.load_model_tokenizer_for_inference()
# Test the model with a prompt
prompt_text = " One of the world's weirdest fish made a rare appearance above the water in these incredible pictures. Photographer Jodi Frediani captured the bizarre-looking Mola mola fish off the coast of California when it surfaced to snack on the Velella velella - a tiny sea creature similar to a jelly fish. But short of shying from the attention, the mola appeared to pucker up for the camera. Scroll down for video . One of the worlds weirdest fish made a rare appearance above the water in these incredible pictures . Sunfish, or Mola mola, are the heaviest of all the bony fish, with large specimens reaching 14 feet (4.2 meters) vertically and 10 feet (3.1 meters) horizontally and weighing nearly 5,000 pounds (2,270 kg). Sharks and rays can be heavier, but they're cartilaginous fish. Sunfish develop their truncated, bullet-like shape because the back fin which they are born with simply never grows. Instead, it folds into itself as the enormous creature matures, creating a rounded rudder called a clavus. Mola in Latin means 'millstone' and describes the ocean sunfish’s somewhat circular shape. They are a silvery color and have a rough skin texture. Mola are found in temperate and tropical oceans around the world. They are frequently seen basking in the sun near the surface and are often mistaken for sharks when their huge dorsal fins emerge above the water. Their teeth are fused into a beak-like structure, and they are unable to fully close their relatively small mouths. Source: NationalGeographic.com . Also known as the ocean sunfish, the creature can grow up to 13 feet (four metres) long and weigh more than 4,400 pounds (2,000 kg). They are sometimes mistaken for sharks when their dorsal fin sticks up out of the water. They feed on Velella velellas, also known as the 'by-the-wind-sailors', which live on the surface and feed on plankton and small fish. Mola mola swim at depths of up to 2,000 feet (600 metres) and spend much of their lives submerged at depths of more than 660 feet (200 metres), which is why it is rare to spot them at the surface of water. Indeed, they tend to live out in the open ocean rather than near shores or the surface. Environmentalist Jodi was on board the whale watching boat the Sea Wolf II in Monterey Bay when she spotted the incredible sight. Jodi said: 'We normally see them resting just below the surface so this was very unusual. 'We were able to watch it as it honed in on one by-the-wind-sailor after another, slurping each into its open mouth, then squirting out a jet of unwanted sea water. 'They swim in a curious, rather clumsy fashion for a fish, wagging their tall dorsal and ventral fins and stubby tails. 'They prefer to feed on jellyfish, but we had the rare opportunity to see one feeding on by-the-wind-sailors.' A Mola mola has not been seen in Monterey Bay for more than eight years . Photographer and environmentalist Jodi Frediani captured the bizarre-looking Mola mola fish off the coast of California when it surfaced to snack on the Velella Velella (shown), a tiny sea creature similar to a jelly fish . Sunfish, or Mola mola, are the heaviest of all the bony fish but tend to live in deeper waters and are rarely seen near the surface . Short of shying from the attention, the Mola mola appeared to pucker up for the camera . Jodi continued: 'Using a special technique to nab the small sailors on the ocean's surface, the Mola mola raised its head out of the water, slurped up the small sailor, then spat it out.' The Mola mola isthe heaviest of all the bony fish, . While they are tame and appear listless, they're difficult to photograph because they are deceptively fast and generally do not like when divers come near them. In addition to this, the sighting was rare - a Mola mola has not been spotted in this Californian bay for more than eight years. In . this separate photo from 2012 photojournalist Daniel Botelho came . across the moon-shaped Mola mola while snapping pictures of blue whales . off San Diego . The Mola mola can grow up to 13 feet (four metres) long and weigh more than 4,400 pounds (2,000 kg) Jodi said: 'We normally see them resting just below the surface so this was very unusual' Mola mola are sometimes mistaken for sharks when their dorsal fin sticks up out of the water ."
responses = inf.generate_response(prompt_text, model,tokenizer)
for response in responses:
print(response)