Barilli studied in Parma with Scaramuzza, in 1862 he won a regional artistic competition with the work Christ converts the publican preserved in the National Gallery. Later he is in Florence and then in 1867 in Paris, where he meets Gustave Dorè and decorates the ceilings of Madame Klaus' palace. He participates in the Salon of that year and that of 1872.
In 1870, at the outbreak of the Franco-Prussian war, he returned to Rome where he lived until 1876 and collaborated with Natali and Bruschi on the decoration of the Quirinal Palace. With Girolamo Magnani in the same building he painted the Triumph of Italy in the party room, obtained from the consistorial apartment of Paolo V. He then decorated with Domenico Bruschi the apartment of Prince Umberto in the Palazzo della Consulta and the exhibition center of the Artistic Association in Via Condotti. Between 1876 and 1877 he painted with Bruschi the Audience Hall of the Corte dei Conti, of the Council Chamber.
At Palazzo Madama on the ceiling of the Senate hall there is a fresco of National Law and a Flora on the ceiling of the Prefecture. He maintains relations with his hometown and participates in the exhibitions of the Academy, to which he is aggregated in 1872.
Returning to Parma in 1878, he becomes Professor of Figure. In 1878 and 1880 he took part in the Turin exhibitions and in 1885 he presented La ciociara. In 1881 he painted the Madonna delle Grazie for the church of Cortemaggiore (PC). In 1886 he frescoed the vault of the Council Chamber of the Parma Town Hall with Girolamo Magnani.
He participates in exhibitions in Nice in 1883 and in London in 1888 and is director of the Pinacoteca and the Academy. In 1890 he became a municipal councilor.